Updated DBA to use own seclib

This commit is contained in:
Andrew 2023-04-12 01:17:53 +07:00
parent c1e8cbf5b3
commit 200d70313a

6
dba.py
View file

@ -1,8 +1,8 @@
from hashlib import sha256
import logging
from secrets import token_hex
from based.db import DBConnector, ColumnCondition, ColumnUpdate, ColumnDefinition
from db_models import *
from secutils import hash_password
logger = logging.getLogger(__name__)
@ -85,7 +85,7 @@ def get_metadata(conn: DBConnector, name: str):
def create_user(conn: DBConnector, username: str, password: str):
try:
hashedPwd = sha256(password.encode("utf-8"), usedforsecurity=True).hexdigest()
hashedPwd = hash_password(password)
conn.insertIntoTable(
USERS_TABLE_NAME,
{"username": username, "password": hashedPwd, "access_token": token_hex()},
@ -144,7 +144,7 @@ def get_user_by_access_token(conn: DBConnector, access_token: str | None):
def check_user(conn: DBConnector, username: str, password: str):
try:
hashedPwd = sha256(password.encode("utf-8"), usedforsecurity=True).hexdigest()
hashedPwd = hash_password(password)
user = conn.filterFromTable(
USERS_TABLE_NAME,
["*"],