From dabdb4b6479ada8c4813727a50c2c47434484803 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 21 Jan 2025 14:24:54 +0000 Subject: [PATCH] auth: Fix logging out Signed-off-by: Michael Tremer --- src/buildservice/sessions.py | 8 ++++++++ src/web/auth.py | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/buildservice/sessions.py b/src/buildservice/sessions.py index eb7a2cfd..0ab736c8 100644 --- a/src/buildservice/sessions.py +++ b/src/buildservice/sessions.py @@ -99,3 +99,11 @@ class Session(database.Base): # User Agent user_agent = Column(Text) + + # Logout! + + async def logout(self): + """ + Destroys this session + """ + await self.db.delete(self) diff --git a/src/web/auth.py b/src/web/auth.py index af89e772..60653895 100644 --- a/src/web/auth.py +++ b/src/web/auth.py @@ -51,9 +51,13 @@ class LogoutHandler(base.BaseHandler): @base.authenticated async def get(self): # Destroy the user's session. - async with self.db.transaction(): + async with await self.db.transaction(): + # Fetch the session + session = await self.get_session() + # Destroy the session - await self.session.destroy() + if session: + session.logout() # Remove the session cookie self.clear_cookie("session_id") -- 2.47.3