Updated DBA to use own seclib
This commit is contained in:
parent
c1e8cbf5b3
commit
200d70313a
1 changed files with 3 additions and 3 deletions
6
dba.py
6
dba.py
|
|
@ -1,8 +1,8 @@
|
||||||
from hashlib import sha256
|
|
||||||
import logging
|
import logging
|
||||||
from secrets import token_hex
|
from secrets import token_hex
|
||||||
from based.db import DBConnector, ColumnCondition, ColumnUpdate, ColumnDefinition
|
from based.db import DBConnector, ColumnCondition, ColumnUpdate, ColumnDefinition
|
||||||
from db_models import *
|
from db_models import *
|
||||||
|
from secutils import hash_password
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
@ -85,7 +85,7 @@ def get_metadata(conn: DBConnector, name: str):
|
||||||
|
|
||||||
def create_user(conn: DBConnector, username: str, password: str):
|
def create_user(conn: DBConnector, username: str, password: str):
|
||||||
try:
|
try:
|
||||||
hashedPwd = sha256(password.encode("utf-8"), usedforsecurity=True).hexdigest()
|
hashedPwd = hash_password(password)
|
||||||
conn.insertIntoTable(
|
conn.insertIntoTable(
|
||||||
USERS_TABLE_NAME,
|
USERS_TABLE_NAME,
|
||||||
{"username": username, "password": hashedPwd, "access_token": token_hex()},
|
{"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):
|
def check_user(conn: DBConnector, username: str, password: str):
|
||||||
try:
|
try:
|
||||||
hashedPwd = sha256(password.encode("utf-8"), usedforsecurity=True).hexdigest()
|
hashedPwd = hash_password(password)
|
||||||
user = conn.filterFromTable(
|
user = conn.filterFromTable(
|
||||||
USERS_TABLE_NAME,
|
USERS_TABLE_NAME,
|
||||||
["*"],
|
["*"],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue