]>
Commit | Line | Data |
---|---|---|
1 | package Gruntmaster::Page::Passwd; | |
2 | ||
3 | use Gruntmaster::Page::Base; | |
4 | use Apache2::Authen::Passphrase qw/pwcheck pwset/; | |
5 | ||
6 | sub generate{ | |
7 | my ($self, $format, $env) = @_; | |
8 | my $r = Plack::Request->new($env); | |
9 | my ($oldpass, $newpass, $confirm) = map {scalar $r->param($_)} 'password', 'new_password', 'confirm_new_password'; | |
10 | ||
11 | return reply 'Incorrect password' unless eval { pwcheck $r->user, $oldpass; 1 }; | |
12 | return reply 'The two passwords do not match' unless $newpass eq $confirm; | |
13 | ||
14 | pwset $r->user, $newpass; | |
15 | reply 'Password changed successfully'; | |
16 | } | |
17 | ||
18 | 1 |