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": {
|
"password": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 8,
|
"minLength": self.helper.minimum_password_length,
|
||||||
"examples": ["crafty"],
|
"examples": ["crafty"],
|
||||||
"title": "Password",
|
"title": "Password",
|
||||||
},
|
},
|
||||||
|
@ -77,11 +77,11 @@ class MainPrompt(cmd.Cmd):
|
|||||||
# get new password from user
|
# get new password from user
|
||||||
new_pass = getpass.getpass(prompt=f"NEW password for: {username} > ")
|
new_pass = getpass.getpass(prompt=f"NEW password for: {username} > ")
|
||||||
# check to make sure it fits our requirements.
|
# check to make sure it fits our requirements.
|
||||||
if len(new_pass) > 512:
|
if len(new_pass) < self.helper.minimum_password_length:
|
||||||
Console.warning("Passwords must be greater than 6char long and under 512")
|
Console.warning(
|
||||||
return False
|
"Passwords must be greater than"
|
||||||
if len(new_pass) < 6:
|
f" {self.helper.minimum_password_length} char long"
|
||||||
Console.warning("Passwords must be greater than 6char long and under 512")
|
)
|
||||||
return False
|
return False
|
||||||
# grab repeated password input
|
# grab repeated password input
|
||||||
new_pass_conf = getpass.getpass(prompt="Re-enter your password: > ")
|
new_pass_conf = getpass.getpass(prompt="Re-enter your password: > ")
|
||||||
|
@ -81,6 +81,7 @@ class Helpers:
|
|||||||
self.update_available = False
|
self.update_available = False
|
||||||
self.ignored_names = ["crafty_managed.txt", "db_stats"]
|
self.ignored_names = ["crafty_managed.txt", "db_stats"]
|
||||||
self.crafty_starting = False
|
self.crafty_starting = False
|
||||||
|
self.minimum_password_length = 8
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def auto_installer_fix(ex):
|
def auto_installer_fix(ex):
|
||||||
|
@ -18,12 +18,19 @@ class DatabaseBuilder:
|
|||||||
logger.info("Fresh Install Detected - Creating Default Settings")
|
logger.info("Fresh Install Detected - Creating Default Settings")
|
||||||
Console.info("Fresh Install Detected - Creating Default Settings")
|
Console.info("Fresh Install Detected - Creating Default Settings")
|
||||||
default_data = self.helper.find_default_password()
|
default_data = self.helper.find_default_password()
|
||||||
if password not in default_data:
|
if "password" not in default_data:
|
||||||
Console.help(
|
Console.help(
|
||||||
"No default password found. Using password created "
|
"No default password found. Using password created "
|
||||||
"by Crafty. Find it in app/config/default-creds.txt"
|
"by Crafty. Find it in app/config/default-creds.txt"
|
||||||
)
|
)
|
||||||
username = default_data.get("username", "admin")
|
username = default_data.get("username", "admin")
|
||||||
|
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)
|
password = default_data.get("password", password)
|
||||||
|
|
||||||
self.users_helper.add_user(
|
self.users_helper.add_user(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user