summaryrefslogtreecommitdiff
path: root/httemplate/misc
diff options
context:
space:
mode:
authorChristopher Burger <burgerc@freeside.biz>2017-06-20 09:04:14 -0400
committerChristopher Burger <burgerc@freeside.biz>2017-06-20 09:04:14 -0400
commit2eefefbe2f93bd6f306c7f73443028dbfd70782e (patch)
tree01888b94bac72a8d7ec8c85ea439a6d0a1749e59 /httemplate/misc
parent0cf46c59eb42596a1823f70e8facf2f457c0e43b (diff)
RT# 75817 - Added the ability to set contacts password on the backend
Diffstat (limited to 'httemplate/misc')
-rw-r--r--httemplate/misc/process/change-password.html71
-rw-r--r--httemplate/misc/xmlhttp-validate_password.html34
2 files changed, 78 insertions, 27 deletions
diff --git a/httemplate/misc/process/change-password.html b/httemplate/misc/process/change-password.html
index d58ce544d..250e8320b 100644
--- a/httemplate/misc/process/change-password.html
+++ b/httemplate/misc/process/change-password.html
@@ -1,28 +1,63 @@
<%init>
my $curuser = $FS::CurrentUser::CurrentUser;
-$cgi->param('svcnum') =~ /^(\d+)$/ or die "illegal svcnum";
+$cgi->param('svcnum') =~ /^(\d+)$/ or die "illegal svcnum" if $cgi->param('svcnum');
my $svcnum = $1;
-my $svc_acct = FS::svc_acct->by_key($svcnum)
- or die "svc_acct $svcnum not found";
-my $part_svc = $svc_acct->part_svc;
-die "access denied" unless (
- $curuser->access_right('Provision customer service') or
- ( $curuser->access_right('Edit password') and
- ! $part_svc->restrict_edit_password )
- );
+
+$cgi->param('contactnum') =~ /^(\d+)$/ or die "illegal contactnum" if $cgi->param('contactnum');
+my $contactnum = $1;
+
my $newpass = $cgi->param('password');
-my $error = $svc_acct->is_password_allowed($newpass)
- || $svc_acct->set_password($newpass)
- || $svc_acct->replace;
-# annoyingly specific to view/svc_acct.cgi, for now...
-$cgi->delete('password');
+my $error;
+
+if ($svcnum) {
+ my $svc_acct = FS::svc_acct->by_key($svcnum)
+ or die "svc_acct $svcnum not found";
+ my $part_svc = $svc_acct->part_svc;
+ die "access denied" unless (
+ $curuser->access_right('Provision customer service') or
+ ( $curuser->access_right('Edit password') and
+ ! $part_svc->restrict_edit_password )
+ );
+
+ my $error = $svc_acct->is_password_allowed($newpass)
+ || $svc_acct->set_password($newpass)
+ || $svc_acct->replace;
+
+ # annoyingly specific to view/svc_acct.cgi, for now...
+ $cgi->delete('password');
+}
+elsif ($contactnum) {
+ my $contact = qsearchs('contact', { 'contactnum' => $contactnum } )
+ or return { 'error' => "Contact not found" . $contactnum };
+
+ my $error = $contact->is_password_allowed($newpass)
+ || $contact->change_password($newpass);
+
+ # annoyingly specific to view/svc_acct.cgi, for now...
+ #$cgi->delete('password');
+}
+
</%init>
% if ( $error ) {
-% $cgi->param('svcnum', $svcnum);
-% $cgi->param("changepw${svcnum}_error", $error);
+% if ($svcnum) {
+% $cgi->param('svcnum', $svcnum);
+% $cgi->param("changepw${svcnum}_error", $error);
+% }
+% elsif ($contactnum) {
+% $cgi->param('contactnum', $contactnum);
+% $cgi->param("changepw${contactnum}_error", $error);
+% }
% } else {
-% $cgi->query_string($svcnum);
+% if ($svcnum) { $cgi->query_string($svcnum); }
+% elsif ($contactnum) { $cgi->query_string($contactnum); }
+% }
+%warn('my pwd error is ' . $error . ' end');
+% if ($svcnum) {
+ <% $cgi->redirect($fsurl.'view/svc_acct.cgi?'.$cgi->query_string) %>
% }
-<% $cgi->redirect($fsurl.'view/svc_acct.cgi?'.$cgi->query_string) %>
+% elsif ($contactnum) {
+ <% $cgi->redirect($fsurl.'edit/cust_main-contacts.html?'.$cgi->param('custnum')) %>
+% }
+
diff --git a/httemplate/misc/xmlhttp-validate_password.html b/httemplate/misc/xmlhttp-validate_password.html
index 28dbf6460..4d9716bb9 100644
--- a/httemplate/misc/xmlhttp-validate_password.html
+++ b/httemplate/misc/xmlhttp-validate_password.html
@@ -28,17 +28,33 @@ my $validate_password = sub {
$result{'syserror'} = 'Invoked without password' unless $password;
return \%result if $result{'syserror'};
- my $svcnum = $arg{'svcnum'};
- $result{'syserror'} = 'Invalid svcnum' unless $svcnum =~ /^\d*$/;
- return \%result if $result{'syserror'};
+ if ($arg{'contactnum'}) {
+ my $contactnum = $arg{'contactnum'};
+ $result{'syserror'} = 'Invalid contactnum' unless $contactnum =~ /^\d*$/;
+ return \%result if $result{'syserror'};
- my $svc_acct = $svcnum
- ? qsearchs('svc_acct',{'svcnum' => $svcnum})
- : (new FS::svc_acct {});
- $result{'syserror'} = 'Could not find service' unless $svc_acct;
- return \%result if $result{'syserror'};
+ my $contact = $contactnum
+ ? qsearchs('contact',{'contactnum' => $contactnum})
+ : '';
+
+ $result{'error'} = $contact->is_password_allowed($password);
+ }
+
+ if ($arg{'svcnum'}) {
+ my $svcnum = $arg{'svcnum'};
+ $result{'syserror'} = 'Invalid svcnum' unless $svcnum =~ /^\d*$/;
+ return \%result if $result{'syserror'};
+
+ my $svc_acct = $svcnum
+ ? qsearchs('svc_acct',{'svcnum' => $svcnum})
+ : (new FS::svc_acct {});
+ $result{'syserror'} = 'Could not find service' unless $svc_acct;
+ return \%result if $result{'syserror'};
+
+ $result{'error'} = $svc_acct->is_password_allowed($password);
+ }
- $result{'error'} = $svc_acct->is_password_allowed($password);
+ # $result{'error'} = $svc_acct->is_password_allowed($password);
$result{'valid'} = 1 unless $result{'error'};
return \%result;
};