mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-19 01:35:28 +01:00
Refactor minimum password length
This commit is contained in:
parent
bfa0c72412
commit
842e576b5c
@ -52,7 +52,7 @@ class UsersController:
|
||||
},
|
||||
"password": {
|
||||
"type": "string",
|
||||
"minLength": 8,
|
||||
"minLength": self.helper.minimum_password_length,
|
||||
"examples": ["crafty"],
|
||||
"title": "Password",
|
||||
},
|
||||
|
@ -77,11 +77,11 @@ class MainPrompt(cmd.Cmd):
|
||||
# get new password from user
|
||||
new_pass = getpass.getpass(prompt=f"NEW password for: {username} > ")
|
||||
# check to make sure it fits our requirements.
|
||||
if len(new_pass) > 512:
|
||||
Console.warning("Passwords must be greater than 6char long and under 512")
|
||||
return False
|
||||
if len(new_pass) < 6:
|
||||
Console.warning("Passwords must be greater than 6char long and under 512")
|
||||
if len(new_pass) < self.helper.minimum_password_length:
|
||||
Console.warning(
|
||||
"Passwords must be greater than"
|
||||
f" {self.helper.minimum_password_length} char long"
|
||||
)
|
||||
return False
|
||||
# grab repeated password input
|
||||
new_pass_conf = getpass.getpass(prompt="Re-enter your password: > ")
|
||||
|
@ -81,6 +81,7 @@ class Helpers:
|
||||
self.update_available = False
|
||||
self.ignored_names = ["crafty_managed.txt", "db_stats"]
|
||||
self.crafty_starting = False
|
||||
self.minimum_password_length = 8
|
||||
|
||||
@staticmethod
|
||||
def auto_installer_fix(ex):
|
||||
|
@ -18,13 +18,20 @@ class DatabaseBuilder:
|
||||
logger.info("Fresh Install Detected - Creating Default Settings")
|
||||
Console.info("Fresh Install Detected - Creating Default Settings")
|
||||
default_data = self.helper.find_default_password()
|
||||
if password not in default_data:
|
||||
if "password" not in default_data:
|
||||
Console.help(
|
||||
"No default password found. Using password created "
|
||||
"by Crafty. Find it in app/config/default-creds.txt"
|
||||
)
|
||||
username = default_data.get("username", "admin")
|
||||
password = default_data.get("password", password)
|
||||
if self.helper.minimum_password_length > default_data.get("password", password):
|
||||
Console.critical(
|
||||
"Default password too short"
|
||||
" using Crafty's created default."
|
||||
" Find it in app/config/default-creds.txt"
|
||||
)
|
||||
else:
|
||||
password = default_data.get("password", password)
|
||||
|
||||
self.users_helper.add_user(
|
||||
username=username,
|
||||
|
Loading…
x
Reference in New Issue
Block a user