3 % $cgi->param('svcnum', $svcnum);
4 % $cgi->param("changepw${svcnum}_error", $error);
6 % elsif ($contactnum) {
7 % $cgi->param('contactnum', $contactnum);
8 % $cgi->param("changepw${contactnum}_error", $error);
10 % $cgi->param('error', $error);
12 % if ($svcnum) { $cgi->query_string($svcnum); }
13 % elsif ($contactnum) { $cgi->query_string($contactnum); }
18 <% $cgi->redirect($fsurl.'view/svc_acct.cgi?'.$cgi->query_string) %>
20 % elsif ($contactnum) {
21 % my $freeside_status = "Contact ".$contact->{'Hash'}->{'first'}." ".$contact->{'Hash'}->{'last'}." password updated.";
22 <% $cgi->redirect( -uri => popurl(3). "view/cust_main.cgi?". $cgi->param('custnum'),
23 -cookie => CGI::Cookie->new(
24 -name => 'freeside_status',
25 -value => mt($freeside_status),
33 <& /elements/header-popup.html, 'Password Set' &>
34 <SCRIPT TYPE="text/javascript">
40 my $curuser = $FS::CurrentUser::CurrentUser;
43 $cgi->param('svcnum') =~ /^(\d+)$/ or die "illegal svcnum" if $cgi->param('svcnum');
46 foreach my $prefix (grep /^(.*)(password)$/, $cgi->param) {
47 $cgi->param('password' => $cgi->param($prefix));
50 $cgi->param('contactnum') =~ /^(\d+)$/ or die "illegal contactnum" if $cgi->param('contactnum');
53 my $popup = $cgi->param('popup');
55 my $newpass = $cgi->param('password');
60 my $svc_acct = FS::svc_acct->by_key($svcnum)
61 or die "svc_acct $svcnum not found";
62 my $part_svc = $svc_acct->part_svc;
63 die "access denied" unless (
64 $curuser->access_right('Provision customer service') or
65 ( $curuser->access_right('Edit password') and
66 ! $part_svc->restrict_edit_password )
69 $error = $svc_acct->is_password_allowed($newpass)
70 || $svc_acct->set_password($newpass)
71 || $svc_acct->replace;
73 # annoyingly specific to view/svc_acct.cgi, for now...
74 $cgi->delete('password');
77 $contact = qsearchs('contact', { 'contactnum' => $contactnum } )
78 or return { 'error' => "Contact not found" . $contactnum };
80 $error = $contact->is_password_allowed($newpass)
81 || $contact->change_password($newpass);
83 # annoyingly specific to view/svc_acct.cgi, for now...
84 #$cgi->delete('password');