Changing Password for user <%$user|h%>

<& SELF:error &> % unless (defined $cmd and $cmd eq 'change'){ <& SELF:change &> % } <%args> $pw1 => undef $pw2 => undef $cmd => undef <%shared> my $user = $m->session->{user}; my $userip = $r->connection->client_ip; my $secure = &is_secure; my $err = ''; <%init> # Send to https if not secure. unless ($secure){ my $url = url_secure($r->uri); $m->redirect($url); } unless ($user){ $err = "Who are you?"; $cmd = undef; } unless ($m->session->{useuserdb}) { $err = "You can't change your apache password this way."; $cmd = undef; } if ($cmd eq 'change'){ unless ($pw1 eq $pw2){ $err = "Passwords do not match.
"; } unless ($err){ my $rv = netdisco::user_add($user,('pw' => $pw1)); $err .= $rv ? "Could not Change Password! $rv
\n" : "Password for $user changed.
\n"; # Log Change Password insert_or_update('user_log',{}, {'username'=>$user,'event'=>'pw_change', 'userip'=>$userip,'details' => $rv ? 'Failed' : 'Succeeded'}); } undef $cmd; } <%method change>
<%method error> % return unless $err;

<%$err%>

<%method title> - Change Password \ %# $Id$ %# vim:syntax=mason