diff --git a/advlabdb/model_independent_funs.py b/advlabdb/model_independent_funs.py index 68eb766..e5dcaee 100644 --- a/advlabdb/model_independent_funs.py +++ b/advlabdb/model_independent_funs.py @@ -1,19 +1,21 @@ # Functions not dependent on advlabdb.models -from random import choice +import secrets from string import ascii_letters, digits from sqlalchemy import func, select from . import app, db +PASSWORD_CHARS: str = ascii_letters + digits + "!%*+=?" -def randomPassword(): + +def randomPassword() -> str: password_length = app.config["SECURITY_PASSWORD_LENGTH_MIN"] - return "".join(choice(ascii_letters + digits) for i in range(password_length)) + return "".join(secrets.choice(PASSWORD_CHARS) for i in range(password_length)) -def reportBadAttempt(message): +def reportBadAttempt(message: str) -> None: print("BAD ATTEMPT:", message) # TODO: Log