summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--authentication/endpoints.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/authentication/endpoints.py b/authentication/endpoints.py
index 18f3ba6..6877383 100644
--- a/authentication/endpoints.py
+++ b/authentication/endpoints.py
@@ -64,21 +64,21 @@ async def post_login(request: Request, username: Annotated[str, Form()] = '', pa
64 'username': username, 64 'username': username,
65 'password': password 65 'password': password
66 }) 66 })
67
67 with get_session_context() as db_session: 68 with get_session_context() as db_session:
68 user = db_session.query(User).filter(User.username == form.username).first() 69 user = db_session.query(User).filter(User.username == form.username).first()
69 70
70 if not bcrypt_sha256_verify(password, user.password if user is not None else '') or user is None: 71 if not bcrypt_sha256_verify(password, user.password if user is not None else '') or user is None:
71 errors.update({'password': 'Invalid username or password'}) 72 errors.update({'password': 'Invalid username or password'})
73 else:
74 with get_session_context() as db_session:
75 session = Session(id=uuid7(), user=user)
76 db_session.add(session)
72 77
73 with get_session_context() as db_session: 78 request.session.update({'id': str(session.id)})
74 session = Session(id=uuid7(), user=user)
75 db_session.add(session)
76
77 request.session.update({'id': str(session.id)})
78
79 if next is not None:
80 return RedirectResponse(next, status_code=303)
81 79
80 if next is not None:
81 return RedirectResponse(next, status_code=303)
82 except ValidationError as exc: 82 except ValidationError as exc:
83 errors.update({e['loc'][0]: e['msg'] for e in exc.errors()}) 83 errors.update({e['loc'][0]: e['msg'] for e in exc.errors()})
84 84