From f15cc5feae895ec11aa626b689ad9c0fd199c8d7 Mon Sep 17 00:00:00 2001 From: Maria Rice Date: Tue, 9 Jan 2018 14:10:21 -0600 Subject: [PATCH] added check to create user form and made update password submission erase all fields --- .../assets/js/panelHandlers/users/new.js | 35 +++++++++++-------- .../js/panelHandlers/users/new_password.js | 3 ++ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/server/document_root/assets/js/panelHandlers/users/new.js b/server/document_root/assets/js/panelHandlers/users/new.js index 0ff0580..d81048b 100644 --- a/server/document_root/assets/js/panelHandlers/users/new.js +++ b/server/document_root/assets/js/panelHandlers/users/new.js @@ -9,28 +9,33 @@ jQuery('._js_add-user-form').on('submit', function(e){ if((usernameInput && usernameInput.val()) && (passwordInput && passwordInput.val()) && (passwordInputRetype && passwordInputRetype.val())) { if(passwordInput.val() == passwordInputRetype.val()) { - var requestData = {}; - requestData["user"] = usernameInput.val(); - requestData["pass"] = passwordInput.val(); + if (passwordInput.val().length >= 8) { + var requestData = {}; + requestData["user"] = usernameInput.val(); + requestData["pass"] = passwordInput.val(); - var xhr = new XMLHttpRequest(); - xhr.open(jQuery(this).attr('method'), jQuery(this).attr('action'), true); - xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); - xhr.send(JSON.stringify(requestData)); + var xhr = new XMLHttpRequest(); + xhr.open(jQuery(this).attr('method'), jQuery(this).attr('action'), true); + xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); + xhr.send(JSON.stringify(requestData)); - xhr.onloadend = function() { - if(xhr.status == 204) { - listCurrentUsers(); - } - else { - if(xhr.response != undefined && xhr.response.length != 0) { - alert('Error: ' + xhr.response); + xhr.onloadend = function() { + if(xhr.status == 204) { + listCurrentUsers(); } else { - alert('An error has occurred, refresh and try again. If problem persists please contact your administrator.'); + if(xhr.response != undefined && xhr.response.length != 0) { + alert('Error: ' + xhr.response); + } + else { + alert('An error has occurred, refresh and try again. If problem persists please contact your administrator.'); + } } } } + else { + alert('Password must be at least 8 characters'); + } } else { alert('Password fields do not match.'); diff --git a/server/document_root/assets/js/panelHandlers/users/new_password.js b/server/document_root/assets/js/panelHandlers/users/new_password.js index af8e909..d9653e6 100644 --- a/server/document_root/assets/js/panelHandlers/users/new_password.js +++ b/server/document_root/assets/js/panelHandlers/users/new_password.js @@ -50,6 +50,9 @@ jQuery('._js_update-password-form').on('submit', function(e){ xhr.onloadend = function() { if(xhr.status == 204) { alert("Password successfully updated."); + $('input[type=password]').each(function() { + $(this).val(''); + }); newPassModal.modal('hide'); userModal.modal('show'); }