Skip to content

Commit 1ed136d

Browse files
committed
display invalid reason in <p> like the rest of the page
1 parent 5870d27 commit 1ed136d

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

webroot/panel/account.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@
225225
?>
226226
<br>
227227
<input id='submitLoginShell' type='submit' value='Set Login Shell' />
228+
<label id='labelSubmitLoginShell'> <!-- value set by JS --> </label>
228229
</form>
229230
<hr>
230231

@@ -297,14 +298,17 @@ function getNewLoginShell() {
297298
}
298299

299300
function isLoginShellValid(x) {
300-
if (x.trim().length === 0) {
301-
return false;
301+
if (/^\s|\s$/.test(x)) {
302+
return [false, "must not have leading or trailing whitespace"];
303+
}
304+
if (x.length === 0) {
305+
return [false, "must not be empty"];
302306
}
303307
// only ascii characters allowed
304308
if (!(/^[\x00-\x7F]*$/.test(x))) {
305-
return false;
309+
return [false, "must only contain ASCII characters"];
306310
}
307-
return true;
311+
return [true, ""];
308312
}
309313

310314
function enableOrDisableCustomLoginBoxHighlight() {
@@ -323,18 +327,21 @@ function enableOrDisableCustomLoginBoxHighlight() {
323327

324328
function enableOrDisableSubmitLoginShell() {
325329
var newLoginShell = getNewLoginShell();
326-
if (!isLoginShellValid(newLoginShell)) {
330+
isValidArr = isLoginShellValid(newLoginShell);
331+
isValid = isValidArr[0];
332+
isValidReason = isValidArr[1];
333+
if (!isValid) {
327334
$("#submitLoginShell").prop("disabled", true);
328-
$("#submitLoginShell").prop("title", "Invalid Login Shell");
335+
$("#labelSubmitLoginShell").text(`(invalid login shell: ${isValidReason})`);
329336
return;
330337
}
331338
if (newLoginShell == ldapLoginShell) {
332339
$("#submitLoginShell").prop("disabled", true);
333-
$("#submitLoginShell").prop("title", "Login Shell Unchanged");
340+
$("#labelSubmitLoginShell").text("(no change)");
334341
return;
335342
}
336343
$("#submitLoginShell").prop("disabled", false);
337-
$("#submitLoginShell").prop("title", "Submit Login Shell");
344+
$("#labelSubmitLoginShell").text("");
338345
}
339346
$("#customLoginBox").on("input", enableOrDisableSubmitLoginShell);
340347
$("#loginSelector").change(enableOrDisableSubmitLoginShell);

0 commit comments

Comments
 (0)