[freeside-commits] branch FREESIDE_4_BRANCH updated. a0122c42d698589cc46d6bddfe217b8f9c762fc5
Jonathan Prykop
jonathan at 420.am
Tue Dec 20 10:32:58 PST 2016
The branch, FREESIDE_4_BRANCH has been updated
via a0122c42d698589cc46d6bddfe217b8f9c762fc5 (commit)
from 4d4dc3e852e5ff1ca883e2003b0b2e95db0e5414 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a0122c42d698589cc46d6bddfe217b8f9c762fc5
Author: Jonathan Prykop <jonathan at freeside.biz>
Date: Sat Dec 17 19:53:23 2016 -0600
73443: Selfservice NG Password reset page
diff --git a/FS/FS/ClientAPI_XMLRPC.pm b/FS/FS/ClientAPI_XMLRPC.pm
index 3167aa0..e69a06e 100644
--- a/FS/FS/ClientAPI_XMLRPC.pm
+++ b/FS/FS/ClientAPI_XMLRPC.pm
@@ -181,6 +181,7 @@ sub ss2clientapi {
'reset_passwd' => 'MyAccount/reset_passwd',
'check_reset_passwd' => 'MyAccount/check_reset_passwd',
'process_reset_passwd' => 'MyAccount/process_reset_passwd',
+ 'validate_passwd' => 'MyAccount/validate_passwd',
'list_tickets' => 'MyAccount/list_tickets',
'create_ticket' => 'MyAccount/create_ticket',
'get_ticket' => 'MyAccount/get_ticket',
diff --git a/ng_selfservice/elements/add_password_validation.php b/ng_selfservice/elements/add_password_validation.php
new file mode 100644
index 0000000..6938437
--- /dev/null
+++ b/ng_selfservice/elements/add_password_validation.php
@@ -0,0 +1,51 @@
+<SCRIPT>
+function add_password_validation (fieldid,nologin) {
+ var inputfield = document.getElementById(fieldid);
+ inputfield.onchange = function () {
+ var fieldid = this.id+'_result';
+ var resultfield = document.getElementById(fieldid);
+ var svcnum = '';
+ var svcfield = document.getElementById(this.id+'_svcnum');
+ if (svcfield) {
+ svcnum = svcfield.options[svcfield.selectedIndex].value;
+ }
+ if (this.value) {
+ resultfield.innerHTML = '<SPAN STYLE="color: blue;">Validating password...</SPAN>';
+ var validate_data = {
+ fieldid: fieldid,
+ check_password: this.value,
+ };
+ if (!nologin) {
+ validate_data['svcnum'] = svcnum;
+ }
+ $.ajax({
+ url: 'xmlrpc_validate_passwd.php',
+ data: validate_data,
+ method: 'POST',
+ success: function ( result ) {
+ result = JSON.parse(result);
+ var resultfield = document.getElementById(fieldid);
+ if (resultfield) {
+ var errorimg = '<IMG SRC="images/error.png" style="width: 1em; display: inline-block; padding-right: .5em">';
+ var validimg = '<IMG SRC="images/tick.png" style="width: 1em; display: inline-block; padding-right: .5em">';
+ if (result.password_valid) {
+ resultfield.innerHTML = validimg+'<SPAN STYLE="color: green;">Password valid!</SPAN>';
+ } else if (result.password_invalid) {
+ resultfield.innerHTML = errorimg+'<SPAN STYLE="color: red;">'+result.password_invalid+'</SPAN>';
+ } else {
+ resultfield.innerHTML = '';
+ }
+ }
+ },
+ error: function ( jqXHR, textStatus, errorThrown ) {
+ var resultfield = document.getElementById(fieldid);
+ console.log('ajax error: '+textStatus+'+'+errorThrown);
+ if (resultfield) {
+ resultfield.innerHTML = '';
+ }
+ },
+ });
+ }
+ };
+}
+</SCRIPT>
diff --git a/ng_selfservice/images/error.png b/ng_selfservice/images/error.png
new file mode 100644
index 0000000..628cf2d
Binary files /dev/null and b/ng_selfservice/images/error.png differ
diff --git a/ng_selfservice/images/tick.png b/ng_selfservice/images/tick.png
new file mode 100644
index 0000000..a9925a0
Binary files /dev/null and b/ng_selfservice/images/tick.png differ
diff --git a/ng_selfservice/password.php b/ng_selfservice/password.php
index 41296ed..a6e6795 100644
--- a/ng_selfservice/password.php
+++ b/ng_selfservice/password.php
@@ -1,5 +1,92 @@
<? $title ='Change Password'; include('elements/header.php'); ?>
<? $current_menu = 'password.php'; include('elements/menu.php'); ?>
-Chagne password
+<?
+$error = '';
+$pwd_change_success = false;
+if ( isset($_POST['svcnum']) ) {
+
+ $pwd_change_result = $freeside->myaccount_passwd(array(
+ 'session_id' => $_COOKIE['session_id'],
+ 'svcnum' => $_POST['svcnum'],
+ 'new_password' => $_POST['new_password'],
+ 'new_password2' => $_POST['new_password2'],
+ ));
+
+ if ($pwd_change_result['error']) {
+ $error = $pwd_change_result['error'];
+ } else {
+ $pwd_change_success = true;
+ }
+}
+
+if ($pwd_change_success) {
+?>
+
+<P>Password changed for <? echo $pwd_change_result['value'],' ',$pwd_change_result['label'] ?>.</P>
+
+<?
+} else {
+ $pwd_change_svcs = $freeside->list_svcs(array(
+ 'session_id' => $_COOKIE['session_id'],
+ 'svcdb' => 'svc_acct',
+ ));
+ if (isset($pwd_change_svcs['error'])) {
+ $error = $error || $pwd_change_svcs['error'];
+ }
+ if (!isset($pwd_change_svcs['svcs'])) {
+ $pwd_change_svcs['svcs'] = $pwd_change_svcs['svcs'];
+ $error = $error || 'Unknown error loading services';
+ }
+ if ($error) {
+ include('elements/error.php');
+ }
+?>
+
+<FORM METHOD="POST">
+<TABLE BGCOLOR="#cccccc">
+ <TR>
+ <TH ALIGN="right">Change password for account: </TH>
+ <TD>
+ <SELECT ID="new_password_svcnum" NAME="svcnum">
+<?
+ $selected_svcnum = isset($_POST['svcnum']) ? $_POST['svcnum'] : $pwd_change_svcs['svcnum'];
+ foreach ($pwd_change_svcs['svcs'] as $svc) {
+?>
+ <OPTION VALUE="<? echo $svc['svcnum'] ?>"<? echo $selected_svcnum == $svc['svcnum'] ? ' SELECTED' : '' ?>>
+ <? echo $svc['label'],': ',$svc['value'] ?>
+ </OPTION>
+<?
+ }
+?>
+ </SELECT>
+ </TD>
+ </TR>
+
+ <TR>
+ <TH ALIGN="right">New password: </TH>
+ <TD>
+ <INPUT ID="new_password" TYPE="password" NAME="new_password" SIZE="18">
+ <DIV ID="new_password_result"></DIV>
+<? include('elements/add_password_validation.php'); ?>
+ <SCRIPT>add_password_validation('new_password');</SCRIPT>
+ </TD>
+ </TR>
+
+ <TR>
+ <TH ALIGN="right">Re-enter new password: </TH>
+ <TD><INPUT TYPE="password" NAME="new_password2" SIZE="18"></TD>
+ </TR>
+
+</TABLE>
+<BR>
+
+<INPUT TYPE="submit" VALUE="Change password">
+
+</FORM>
+
+<?
+} // end if $pwd_change_show_form
+?>
+
<? include('elements/menu_footer.php'); ?>
<? include('elements/footer.php'); ?>
diff --git a/ng_selfservice/xmlrpc_validate_passwd.php b/ng_selfservice/xmlrpc_validate_passwd.php
new file mode 100644
index 0000000..5632dc3
--- /dev/null
+++ b/ng_selfservice/xmlrpc_validate_passwd.php
@@ -0,0 +1,15 @@
+<?
+
+require_once('elements/session.php');
+
+$xmlrpc_args = array(
+ fieldid => $_POST['fieldid'],
+ check_password => $_POST['check_password'],
+ svcnum => $_POST['svcnum'],
+ session_id => $_COOKIE['session_id']
+);
+
+$result = $freeside->validate_passwd($xmlrpc_args);
+echo json_encode($result);
+
+?>
-----------------------------------------------------------------------
Summary of changes:
FS/FS/ClientAPI_XMLRPC.pm | 1 +
.../elements/add_password_validation.php | 43 ++++++----
.../cgi => ng_selfservice}/images/error.png | Bin 666 -> 666 bytes
.../cgi => ng_selfservice}/images/tick.png | Bin 537 -> 537 bytes
ng_selfservice/password.php | 89 +++++++++++++++++++-
ng_selfservice/xmlrpc_validate_passwd.php | 15 ++++
6 files changed, 132 insertions(+), 16 deletions(-)
copy fs_selfservice/FS-SelfService/cgi/add_password_validation.js => ng_selfservice/elements/add_password_validation.php (54%)
copy {fs_selfservice/FS-SelfService/cgi => ng_selfservice}/images/error.png (100%)
copy {fs_selfservice/FS-SelfService/cgi => ng_selfservice}/images/tick.png (100%)
create mode 100644 ng_selfservice/xmlrpc_validate_passwd.php
More information about the freeside-commits
mailing list