update auth.py
This commit is contained in:
1 parent
e806cd7e51
commit
3d1d4bcd5d
1 file changed
+17
@@ -1,2 +1,19 @@
|
|||||||
from database import execute
|
from database import execute
|
||||||
import bcrypt
|
import bcrypt
|
||||||
|
|
||||||
|
def create_user(username, password):
|
||||||
|
|
||||||
|
password_hash = bcrypt.hashpw(
|
||||||
|
password.encode(),
|
||||||
|
bcrypt.gensalt()
|
||||||
|
).decode()
|
||||||
|
|
||||||
|
user_id = execute(
|
||||||
|
"""
|
||||||
|
INSERT INTO users (username, password_hash)
|
||||||
|
VALUES (?, ?)
|
||||||
|
""",
|
||||||
|
(username, password_hash)
|
||||||
|
)
|
||||||
|
|
||||||
|
return user_id
|
||||||
Reference in new issue
Block a user