From: Christian Korber Date: Mon, 1 Jun 2026 06:29:55 +0000 (+0200) Subject: luci-base: add helper functions for password X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=62862114f0045ddd526b159f091d9c47e96c752d;p=openwrt-luci.git luci-base: add helper functions for password Because validating password is used in `luci-app-acl` and `luci-mod-system` this commit adds helper functions for them to luci-base. Signed-off-by: Christian Korber --- diff --git a/modules/luci-base/htdocs/luci-static/resources/tools/password.js b/modules/luci-base/htdocs/luci-static/resources/tools/password.js new file mode 100644 index 0000000000..64b451c699 --- /dev/null +++ b/modules/luci-base/htdocs/luci-static/resources/tools/password.js @@ -0,0 +1,32 @@ +'use strict'; + +'require baseclass'; +'require uci'; + +return baseclass.extend({ + checkLength(p, required) { + let enough = p.length >= parseInt(required); + + if (required && !enough) + return false; + + return true; + }, + + checkDigits(p) { + let m = p.match(/\d/); + + return m ? true : false; + }, + + checkUpperLower(p) { + + return /[a-z]/.test(p) && /[A-Z]/.test(p); + }, + + checkSpecialChars(p) { + let m = p.match(/[^a-zA-Z0-9]/); + + return m ? true : false; + } +});