|
257 | 257 |
|
258 | 258 | <hr> |
259 | 259 |
|
260 | | - |
261 | 260 | <script> |
262 | 261 | const sitePrefix = '<?php echo $CONFIG["site"]["prefix"]; ?>'; |
263 | 262 | const ldapLoginShell = '<?php echo $USER->getLoginShell(); ?>'; |
@@ -289,6 +288,57 @@ function showOrHideCustomLoginBox() { |
289 | 288 | $("#loginSelector").change(showOrHideCustomLoginBox); |
290 | 289 | showOrHideCustomLoginBox(); |
291 | 290 |
|
| 291 | + function getNewLoginShell() { |
| 292 | + var loginSelectorVal = $("#loginSelector").val(); |
| 293 | + if (loginSelectorVal != "Custom") { |
| 294 | + return loginSelectorVal; |
| 295 | + } |
| 296 | + return $("#customLoginBox").val(); |
| 297 | + } |
| 298 | + |
| 299 | + function isLoginShellValid(x) { |
| 300 | + if (x.trim().length === 0) { |
| 301 | + return false; |
| 302 | + } |
| 303 | + // only ascii characters allowed |
| 304 | + if (!(/^[\x00-\x7F]*$/.test(x))) { |
| 305 | + return false; |
| 306 | + } |
| 307 | + return true; |
| 308 | + } |
| 309 | + |
| 310 | + function enableOrDisableCustomLoginBoxHighlight() { |
| 311 | + if ( |
| 312 | + ($("#customLoginSelectorOption").prop("selected") == true) && |
| 313 | + !isLoginShellValid($("#customLoginBox").val()) |
| 314 | + ) { |
| 315 | + $("#customLoginBox").css("box-shadow", "0 0 0 0.3rem rgba(220, 53, 69, 0.25)"); |
| 316 | + } else { |
| 317 | + $("#customLoginBox").css("box-shadow", "none"); |
| 318 | + } |
| 319 | + } |
| 320 | + $("#customLoginBox").on("input", enableOrDisableCustomLoginBoxHighlight); |
| 321 | + $("#loginSelector").change(enableOrDisableCustomLoginBoxHighlight); |
| 322 | + enableOrDisableCustomLoginBoxHighlight(); |
| 323 | + |
| 324 | + function enableOrDisableSubmitLoginShell() { |
| 325 | + var newLoginShell = getNewLoginShell(); |
| 326 | + if (!isLoginShellValid(newLoginShell)) { |
| 327 | + $("#submitLoginShell").prop("disabled", true); |
| 328 | + $("#submitLoginShell").prop("title", "Invalid Login Shell"); |
| 329 | + return; |
| 330 | + } |
| 331 | + if (newLoginShell == ldapLoginShell) { |
| 332 | + $("#submitLoginShell").prop("disabled", true); |
| 333 | + $("#submitLoginShell").prop("title", "Login Shell Unchanged"); |
| 334 | + return; |
| 335 | + } |
| 336 | + $("#submitLoginShell").prop("disabled", false); |
| 337 | + $("#submitLoginShell").prop("title", "Submit Login Shell"); |
| 338 | + } |
| 339 | + $("#customLoginBox").on("input", enableOrDisableSubmitLoginShell); |
| 340 | + $("#loginSelector").change(enableOrDisableSubmitLoginShell); |
| 341 | + enableOrDisableSubmitLoginShell() |
292 | 342 | </script> |
293 | 343 |
|
294 | 344 | <style> |
|
0 commit comments