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
+5 -4
View File
@@ -1,6 +1,6 @@
import json
from app.models.user import User
from app.utils.auth import encode_password
from app.utils.auth import hash_password
from app.db.sqlite.utils import SQLiteManager
@@ -44,7 +44,7 @@ class SQLiteAuthMethods:
"""
user = {
"username": "admin",
"password": encode_password("admin"),
"password": hash_password("admin"),
"roles": json.dumps(["admin"]),
}
return SQLiteAuthMethods.insert_user(user)
@@ -56,7 +56,7 @@ class SQLiteAuthMethods:
"""
user = {
"username": "guest",
"password": encode_password("guest"),
"password": hash_password("guest"),
"roles": json.dumps(["guest"]),
}
@@ -67,7 +67,7 @@ class SQLiteAuthMethods:
"""
Update a user in the database.
:param user: A dict with the username, password and roles.
:param user: A dict with the user id and the fields to update. Ommited fields will not be updated.
"""
# get all user dict keys
keys = list(user.keys())
@@ -75,6 +75,7 @@ class SQLiteAuthMethods:
{', '.join([f"{key} = :{key}" for key in keys if key != 'id'])}
WHERE id = :id
"""
print(sql, user)
with SQLiteManager(userdata_db=True) as cur:
cur.execute(sql, user)