22 lines
534 B
Python
22 lines
534 B
Python
from tinydb import TinyDB, Query
|
|
|
|
db = TinyDB("./database.json")
|
|
users = db.table("users");
|
|
|
|
def get_users():
|
|
return (users.all())
|
|
|
|
def get_user_by_email(email: str):
|
|
for user in get_users():
|
|
if (list(user.keys())[0] == email):
|
|
return (user);
|
|
|
|
def user_exist(email: str):
|
|
return (get_user_by_email(email) != None)
|
|
|
|
def add_user(email: str, password: str):
|
|
users.insert({email: password});
|
|
|
|
def check_password(email: str, password: str):
|
|
return (get_user_by_email(email).get(email) == password)
|