Improvements for password verify (addresses: https://github.com/iiab/calibre-web/pull/138)

This commit is contained in:
Ozzie Isaacs 2024-03-10 16:39:06 +01:00
parent 14b578dd3a
commit fcc95bd895
2 changed files with 6 additions and 6 deletions

View File

@ -696,15 +696,15 @@ def valid_password(check_password):
if config.config_password_min_length > 0: if config.config_password_min_length > 0:
verify += r"^(?=.{" + str(config.config_password_min_length) + ",}$)" verify += r"^(?=.{" + str(config.config_password_min_length) + ",}$)"
if config.config_password_number: if config.config_password_number:
verify += "(?=.*?\d)" verify += r"(?=.*?\d)"
if config.config_password_lower: if config.config_password_lower:
verify += "(?=.*?[\p{Ll}])" verify += r"(?=.*?[\p{Ll}])"
if config.config_password_upper: if config.config_password_upper:
verify += "(?=.*?[\p{Lu}])" verify += r"(?=.*?[\p{Lu}])"
if config.config_password_character: if config.config_password_character:
verify += "(?=.*?[\p{Letter}])" verify += r"(?=.*?[\p{Letter}])"
if config.config_password_special: if config.config_password_special:
verify += "(?=.*?[^\p{Letter}\s0-9])" verify += r"(?=.*?[^\p{Letter}\s0-9])"
match = regex.match(verify, check_password) match = regex.match(verify, check_password)
if not match: if not match:
raise Exception(_("Password doesn't comply with password validation rules")) raise Exception(_("Password doesn't comply with password validation rules"))

View File

@ -24,7 +24,7 @@ $(document).ready(function() {
}, },
}, function () { }, function () {
if ($('#password').data("verify")) { if ($('#password').data("verify") === "True") {
// Initialized and ready to go // Initialized and ready to go
var options = {}; var options = {};
options.common = { options.common = {