X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FPasswd.pm;fp=lib%2FGruntmaster%2FPage%2FPasswd.pm;h=4604fbca9e19c6db972d3d8653f7fce65f62ea80;hb=31d700150e564fd3bf0eb167ef416c87aed771eb;hp=0000000000000000000000000000000000000000;hpb=35679f847c4d817b38ec2e894cb64520f2de3e06;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Passwd.pm b/lib/Gruntmaster/Page/Passwd.pm new file mode 100644 index 0000000..4604fbc --- /dev/null +++ b/lib/Gruntmaster/Page/Passwd.pm @@ -0,0 +1,27 @@ +package Gruntmaster::Page::Passwd; + +use 5.014000; +use strict; +use warnings; +use Gruntmaster::Page::Base; +our @ISA = qw/Gruntmaster::Page::Base/; +our $VERSION = '0.001'; + +use Apache2::Authen::Passphrase qw/pwcheck pwset/; +use Plack::Request; + +sub generate{ + my ($self, $format, $env, $ct, $job, $ext) = @_; + my $r = Plack::Request->new($env); + my ($oldpass, $newpass, $confirm) = map {scalar $r->param($_)} 'password', 'new_password', 'confirm_new_password'; + + return reply 'Incorrect password' unless eval { pwcheck $r->user, $oldpass; 1 }; + return reply 'The two passwords do not match' unless $newpass eq $confirm; + + pwset $r->user, $newpass; + reply 'Password changed successfully'; +} + +sub variants{ [[reply => 1, undef, undef, undef, undef, undef]] } + +1