[freeside-commits] branch FREESIDE_3_BRANCH updated. dcc0fd92717b25595ba7cd8a712e2eff10454291

Christopher Burger burgerc at 420.am
Wed Sep 13 07:24:55 PDT 2017


The branch, FREESIDE_3_BRANCH has been updated
       via  dcc0fd92717b25595ba7cd8a712e2eff10454291 (commit)
       via  0a91d21fcf8ebeb12cd71230d79153c1fa0d82a3 (commit)
      from  a84d14e36ad747dcc15cd5a4706e91c7cabb0afb (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 dcc0fd92717b25595ba7cd8a712e2eff10454291
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue Sep 12 12:16:21 2017 -0400

    RT# 77504 - Documented javascript.

diff --git a/httemplate/elements/validate_password.html b/httemplate/elements/validate_password.html
index 8c8cf42..a8c0677 100644
--- a/httemplate/elements/validate_password.html
+++ b/httemplate/elements/validate_password.html
@@ -26,7 +26,9 @@ function add_password_validation (fieldid, submitid) {
   inputfield.onkeydown = function(e) {
     var key;
     if (window.event) { key = window.event.keyCode; }
-    else { key = e.which; }
+    else { key = e.which; } // for ff browsers
+    // some browsers allow the enter key to submit a form even if the submit button is disabled
+    // below prevents enter key from submiting form if password has not been validated.
     if (key == '13') {
       var check = checkPasswordValidation();
       return check;

commit 0a91d21fcf8ebeb12cd71230d79153c1fa0d82a3
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue Sep 12 12:08:41 2017 -0400

    RT# 77504 - Fixed error display issue, and javascript to prevent error.

diff --git a/httemplate/elements/change_password.html b/httemplate/elements/change_password.html
index 463384f..7d95e19 100644
--- a/httemplate/elements/change_password.html
+++ b/httemplate/elements/change_password.html
@@ -13,7 +13,7 @@
 % }
 <DIV ID="<%$pre%>form" CLASS="passwordbox">
 % if (!$opt{'noformtag'}) {
-  <FORM METHOD="POST" ACTION="<%$fsurl%>misc/process/change-password.html">
+  <FORM METHOD="POST" ACTION="<%$fsurl%>misc/process/change-password.html" onsubmit="return checkPasswordValidation()">
 % }
 
     <% $change_id_input %>
@@ -33,9 +33,6 @@
          'contactnum' => $opt{'contact_num'},
          'submitid'   => $change_button_id,
     &>
-% if ( $error ) {
-    <BR><SPAN STYLE="color: #ff0000"><% $error |h %></SPAN>
-% }
 
 % if (!$opt{'noformtag'}) {
   </FORM>
@@ -58,6 +55,16 @@ function <%$pre%>toggle(toggle, clear) {
     toggle ? 'none' : 'inline';
 % }
 }
+
+function checkPasswordValidation()  {
+  var validationResult = document.getElementById('<%$pre%>password_result').innerHTML;
+  if (validationResult.match(/Password valid!/)) {
+    return true;
+  }
+  else {
+    return false;
+  }
+}
 </SCRIPT>
 <%init>
 my %opt = @_;
diff --git a/httemplate/elements/validate_password.html b/httemplate/elements/validate_password.html
index 1b0688e..8c8cf42 100644
--- a/httemplate/elements/validate_password.html
+++ b/httemplate/elements/validate_password.html
@@ -23,6 +23,15 @@ should be the input id plus '_result'.
 <SCRIPT>
 function add_password_validation (fieldid, submitid) {
   var inputfield = document.getElementById(fieldid);
+  inputfield.onkeydown = function(e) {
+    var key;
+    if (window.event) { key = window.event.keyCode; }
+    else { key = e.which; }
+    if (key == '13') {
+      var check = checkPasswordValidation();
+      return check;
+    }
+  }
   inputfield.onkeyup = function () {
     var fieldid = this.id+'_result';
     var resultfield = document.getElementById(fieldid);
diff --git a/httemplate/misc/process/change-password.html b/httemplate/misc/process/change-password.html
index be83786..a3e0601 100644
--- a/httemplate/misc/process/change-password.html
+++ b/httemplate/misc/process/change-password.html
@@ -7,6 +7,7 @@
 %   		$cgi->param('contactnum', $contactnum);
 %   		$cgi->param("changepw${contactnum}_error", $error);
 %	}
+%    $cgi->param('error', $error);
 % } else {
 %	if ($svcnum) { $cgi->query_string($svcnum); }
 %	elsif ($contactnum) { $cgi->query_string($contactnum); }
@@ -52,7 +53,7 @@ if ($svcnum) {
 	    ! $part_svc->restrict_edit_password )
 	  );
 
-	my $error = $svc_acct->is_password_allowed($newpass)
+	$error = $svc_acct->is_password_allowed($newpass)
 	        ||  $svc_acct->set_password($newpass)
 	        ||  $svc_acct->replace;
 
@@ -63,7 +64,7 @@ elsif ($contactnum) {
 	my $contact = qsearchs('contact', { 'contactnum' => $contactnum } )
       or return { 'error' => "Contact not found" . $contactnum };
 
-	my $error = $contact->is_password_allowed($newpass)
+	$error = $contact->is_password_allowed($newpass)
 	        ||  $contact->change_password($newpass);
 
 	# annoyingly specific to view/svc_acct.cgi, for now...
diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi
index 7474779..026effb 100755
--- a/httemplate/view/svc_acct.cgi
+++ b/httemplate/view/svc_acct.cgi
@@ -20,8 +20,9 @@
             "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')",
   ) &>
 
-% } 
+% }
 
+<& /elements/error.html &>
 
 <& elements/svc_radius_usage.html,
               'svc'      => $svc_acct,

-----------------------------------------------------------------------

Summary of changes:
 httemplate/elements/change_password.html     |   15 +++++++++++----
 httemplate/elements/validate_password.html   |   11 +++++++++++
 httemplate/misc/process/change-password.html |    5 +++--
 httemplate/view/svc_acct.cgi                 |    3 ++-
 4 files changed, 27 insertions(+), 7 deletions(-)




More information about the freeside-commits mailing list