update auth.py
This commit is contained in:
@@ -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