Added exception handling
This commit is contained in:
parent
6546fc0401
commit
91518559b0
@ -1,15 +1,22 @@
|
|||||||
import mariadb
|
import mariadb
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
|
||||||
def add_master_pass(
|
def add_master_pass(
|
||||||
id: int, hashed_passwd: bytes, salt: bytes, con: mariadb.Connection
|
id: int, hashed_passwd: bytes, salt: bytes, con: mariadb.Connection
|
||||||
) -> bool:
|
) -> bool:
|
||||||
cursor = con.cursor()
|
cursor = con.cursor()
|
||||||
|
try:
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"INSERT INTO master_pass (user_id, salt, passwd) VALUES (?, ?, ?)",
|
"INSERT INTO master_pass (user_id, salt, passwd) VALUES (?, ?, ?)",
|
||||||
[id, hashed_passwd, salt],
|
[id, hashed_passwd, salt],
|
||||||
)
|
)
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
except Exception:
|
||||||
|
traceback.print_exc()
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def add_account(
|
def add_account(
|
||||||
@ -21,8 +28,14 @@ def add_account(
|
|||||||
con: mariadb.Connection,
|
con: mariadb.Connection,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
cursor = con.cursor()
|
cursor = con.cursor()
|
||||||
|
try:
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"INSERT INTO accounts (user_id, acc_name, salt, enc_login, enc_pass) VALUES (?, ?, ?, ?, ?, ?)",
|
"INSERT INTO accounts (user_id, acc_name, salt, enc_login, enc_pass) VALUES (?, ?, ?, ?, ?, ?)",
|
||||||
[id, acc_name, salt, enc_login, enc_passwd],
|
[id, acc_name, salt, enc_login, enc_passwd],
|
||||||
)
|
)
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
except Exception:
|
||||||
|
traceback.print_exc()
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
Reference in New Issue
Block a user