]> iEval git - gruntmaster-page.git/blobdiff - lib/Gruntmaster/Page/Passwd.pm
Add register and passwd actions
[gruntmaster-page.git] / lib / Gruntmaster / Page / Passwd.pm
diff --git a/lib/Gruntmaster/Page/Passwd.pm b/lib/Gruntmaster/Page/Passwd.pm
new file mode 100644 (file)
index 0000000..4604fbc
--- /dev/null
@@ -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
This page took 0.026367 seconds and 4 git commands to generate.