implement CLI password recovery (hacky :omg:)

+ rewrite migrations logic
+ rename encode_password to hash_password
+ update image sizes (add medium size)
+ rename image endpoints
This commit is contained in:
cwilvx
2024-05-11 21:26:03 +03:00
parent 1e857c1e89
commit b40f05cc7c
21 changed files with 306 additions and 152 deletions
+8 -8
View File
@@ -4,13 +4,13 @@ import hashlib
from app.config import UserConfig
def encode_password(password: str) -> str:
def hash_password(password: str) -> str:
"""
This function encodes the given password.
Hashes the given password using sha256 algorithm and the user id as salt.
:param password: The password to encode.
:param password: The password to hash.
:return: The encoded password.
:return: The hashed password.
"""
return hashlib.pbkdf2_hmac(
@@ -18,14 +18,14 @@ def encode_password(password: str) -> str:
).hex()
def check_password(password: str, encoded: str) -> bool:
def check_password(password: str, hashed: str) -> bool:
"""
This function checks if the given password matches the encoded password.
This function checks if the given password matches the hashed password.
:param password: The password to check.
:param encoded: The encoded password.
:param hashed: The hashed password.
:return: Whether the password matches.
"""
return hmac.compare_digest(encode_password(password), encoded)
return hmac.compare_digest(hash_password(password), hashed)