2022-07-03 16:26:15 +00:00
|
|
|
"""
|
|
|
|
Functions not dependent on advlabdb.models.
|
|
|
|
"""
|
2022-05-16 20:20:36 +00:00
|
|
|
|
2022-07-03 15:46:23 +00:00
|
|
|
import secrets
|
2022-05-29 17:03:54 +00:00
|
|
|
from string import ascii_letters, digits
|
|
|
|
|
2022-08-09 12:46:48 +00:00
|
|
|
from flask import current_app
|
2022-05-29 17:03:54 +00:00
|
|
|
|
2022-07-03 15:46:23 +00:00
|
|
|
PASSWORD_CHARS: str = ascii_letters + digits + "!%*+=?"
|
2022-05-29 17:03:54 +00:00
|
|
|
|
2022-07-03 15:46:23 +00:00
|
|
|
|
|
|
|
def randomPassword() -> str:
|
2022-08-09 12:46:48 +00:00
|
|
|
password_length = current_app.config["SECURITY_PASSWORD_LENGTH_MIN"]
|
2022-07-03 15:46:23 +00:00
|
|
|
return "".join(secrets.choice(PASSWORD_CHARS) for i in range(password_length))
|
2022-05-16 20:20:36 +00:00
|
|
|
|
|
|
|
|
2022-07-03 15:46:23 +00:00
|
|
|
def reportBadAttempt(message: str) -> None:
|
2023-11-01 20:49:10 +00:00
|
|
|
print("BAD ATTEMPT:", message)
|