From: Michael Tremer Date: Tue, 21 Jan 2025 14:24:54 +0000 (+0000) Subject: auth: Fix logging out X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dabdb4b6479ada8c4813727a50c2c47434484803;p=pbs.git auth: Fix logging out Signed-off-by: Michael Tremer --- 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")