3 use BSE::Util::Tags qw(tag_error_img);
5 use base 'BSE::UI::AdminDispatch';
7 our $VERSION = "1.001";
28 my ($class, $req, $msg, $errors) = @_;
30 $msg ||= $req->cgi->param('m');
34 $msg = escape_html($msg);
37 $msg = join "<br />", map escape_html($_), values %$errors;
43 BSE::Util::Tags->basic(undef, $req->cgi, $req->cfg),
44 BSE::Util::Tags->admin(undef, $req->cfg),
45 BSE::Util::Tags->secure($req),
47 error_img => [ \&tag_error_img, $req->cfg, $errors ],
50 return $req->dyn_response('admin/changepw', \%acts);
54 my ($class, $req) = @_;
57 my $oldpw = $cgi->param('oldpassword');
58 my $newpw = $cgi->param('newpassword');
59 my $confirm = $cgi->param('confirm');
61 my $user = $req->user;
64 if (!defined $oldpw || $oldpw eq '') {
65 $errors{oldpassword} = "Enter your current password";
68 $user->check_password($oldpw)
69 or $errors{oldpassword} = "Your old password is incorrect";
71 if (!defined $newpw || $newpw eq '') {
72 $errors{newpassword} = "Enter a new password";
74 if (!defined $confirm || $confirm eq '') {
75 $errors{confirm} = "Enter the confirmation password";
77 if (!$errors{newpassword} && !$errors{confirm}
78 && $newpw ne $confirm) {
79 $errors{confirm} = "Confirmation password does not match new password";
83 and return $class->_field_error($req, \%errors);
84 return $class->req_form($req, undef, \%errors);
87 $user->changepw($newpw);
91 and return $req->json_content(success => 1);
93 my $r = $cgi->param('r');
95 $r = $req->url('menu', { m => "New password saved" });
98 return BSE::Template->get_refresh($r, $req->cfg);