Improved admin account creation dialog box.
Ylian Saint-Hilaire committed
Apr 14, 2020 at 15:09 UTC
475176ce3ae03f5c3fc78a54487873772d0ad6d0
1 file changed
+19
-10
views/default.handlebars
+19
-10
@@ -9876,10 +9876,10 @@
9876
function showCreateNewAccountDialog() {
9877
if (xxdialogMode) return;
9878
var x = '';
9879
- if ((features & 0x200000) == 0) { x += addHtmlValue("Username", '<input id=p4name maxlength=64 onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />'); }
9880
- x += addHtmlValue("Email", '<input id=p4email maxlength=256 onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />');
9881
- x += addHtmlValue("Password", '<input id=p4pass1 type=password maxlength=256 onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />');
9882
- x += addHtmlValue("Password", '<input id=p4pass2 type=password maxlength=256 onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />');
9879
+ if ((features & 0x200000) == 0) { x += addHtmlValue('<span id=p4hname>' + "Username" + '</span>', '<input id=p4name maxlength=64 autocomplete=username onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />'); }
9880
+ x += addHtmlValue('<span id=p4hemail>' + "Email" + '</span>', '<input id=p4email maxlength=256 autocomplete="email" inputmode="email" onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />');
9881
+ x += addHtmlValue('<span id=p4hp1>' + "Password" + '</span>', '<input id=p4pass1 type=password maxlength=256 autocomplete="new-password" onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />');
9882
+ x += addHtmlValue('<span id=p4hp2>' + "Password" + '</span>', '<input id=p4pass2 type=password maxlength=256 autocomplete="new-password" onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />');
9883
x += '<div><label><input id=p4randomPassword onchange=showCreateNewAccountDialogValidate() type=checkbox />' + "Randomize the password." + '</label></div>';
9884
x += '<div><label><input id=p4resetNextLogin onchange=showCreateNewAccountDialogValidate() type=checkbox />' + "Force password reset on next login." + '</label></div>';
9885
x += '<div><label><input id=p4removeEvents onchange=showCreateNewAccountDialogValidate() type=checkbox />' + "Remove all previous events for this userid." + '</label></div>';
@@ -9900,20 +9900,29 @@
9900
}
9901
9902
function showCreateNewAccountDialogValidate() {
9903
- var ve = validateEmail(Q('p4email').value);
9903
+ var emailok = validateEmail(Q('p4email').value);
9904
+ var nameok = true;
9905
+ var passok = (Q('p4pass1').value.length > 0 && Q('p4pass1').value == Q('p4pass2').value && checkPasswordRequirements(Q('p4pass1').value, passRequirements));
9906
+
9907
+ if ((features & 0x200000) == 0) {
9908
+ nameok = (!Q('p4name') || ((Q('p4name').value.length > 0) && (Q('p4name').value.indexOf(' ') == -1)));
9909
+ QS('p4hname').color = nameok?'black':'#7b241c';
9910
+ }
9911
+ QS('p4hemail').color = emailok?'black':'#7b241c';
9912
+
9913
if (serverinfo.emailcheck) {
9914
QE('p4verifiedEmail', ve);
9915
QE('p4invitationEmail', ve && Q('p4resetNextLogin').checked && Q('p4verifiedEmail').checked);
9907
- if (ve == false) { Q('p4verifiedEmail').checked = false; }
9916
+ if (emailok == false) { Q('p4verifiedEmail').checked = false; }
9917
if ((Q('p4resetNextLogin').checked == false) || (Q('p4verifiedEmail').checked == false)) { Q('p4invitationEmail').checked = false; }
9918
}
9919
QE('p4pass1', !Q('p4randomPassword').checked);
9920
QE('p4pass2', !Q('p4randomPassword').checked);
9912
- if (ve == false) { QE('idx_dlgOkButton', false); return; }
9921
+ QS('p4hp1').color = (passok || Q('p4randomPassword').checked)?'black':'#7b241c';
9922
+ QS('p4hp2').color = (passok || Q('p4randomPassword').checked)?'black':'#7b241c';
9923
9914
- var ok = true;
9915
- if ((features & 0x200000) == 0) { ok &= (!Q('p4name') || ((Q('p4name').value.length > 0) && (Q('p4name').value.indexOf(' ') == -1))); } // Username is not email address
9916
- if (Q('p4randomPassword').checked == false) { ok &= (Q('p4pass1').value.length > 0 && Q('p4pass1').value == Q('p4pass2').value && checkPasswordRequirements(Q('p4pass1').value, passRequirements)); }
9924
+ var ok = nameok & emailok;
9925
+ if (Q('p4randomPassword').checked == false) { ok &= passok; }
9926
QE('idx_dlgOkButton', ok);
9927
}
9928