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