Implement a working login function
This commit is contained in:
parent
55974edd37
commit
d3e63fbae9
5
api.py
5
api.py
@ -1,8 +1,6 @@
|
||||
# Imports
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI, HTTPException
|
||||
|
||||
from functions import *
|
||||
|
||||
|
||||
@ -25,6 +23,7 @@ def create_hero(hero: HeroCreate, session: SessionDep):
|
||||
session.refresh(db_hero)
|
||||
return db_hero
|
||||
|
||||
|
||||
@app.get("/heroes/{id}", response_model=Hero)
|
||||
def get_hero(id: int, session: SessionDep):
|
||||
hero = session.get(Hero, id)
|
||||
@ -59,6 +58,8 @@ def delete_hero(id: int, session: SessionDep):
|
||||
@app.post("/verify")
|
||||
def verify_user(email: str, password: str, session: SessionDep):
|
||||
user = get_hero_by_email(email, session)
|
||||
if not user:
|
||||
return {"message": "Authentication failed", "continue": False}
|
||||
# check if the password is correct
|
||||
authenticate_user = verify_password(password, user.hash, user.salt)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user