Spaces:
Running
Running
File size: 556 Bytes
35bbdb3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | """API layer that ties authentication, database, and files together."""
from auth import issue_token, verify_password
from db import find_user, save_user
from files import load_snapshot
def login(email: str, password: str):
rows = find_user(email)
if rows and verify_password(password, rows[0][1]):
return {"token": issue_token(str(rows[0][0]))}
return {"error": "invalid credentials"}
def restore_snapshot(path: str):
return load_snapshot(path)
def register(email: str):
save_user(email)
return {"status": "created"}
|