]>
Commit | Line | Data |
---|---|---|
31d70015 MG |
1 | package Gruntmaster::Page::Passwd; |
2 | ||
31d70015 | 3 | use Gruntmaster::Page::Base; |
31d70015 | 4 | use Apache2::Authen::Passphrase qw/pwcheck pwset/; |
31d70015 MG |
5 | |
6 | sub generate{ | |
8d29b3b1 | 7 | my ($self, $format, $env) = @_; |
31d70015 MG |
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 | ||
31d70015 | 18 | 1 |