]> git.ipfire.org Git - pbs.git/commitdiff
auth: Fix logging out
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Jan 2025 14:24:54 +0000 (14:24 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Jan 2025 14:24:54 +0000 (14:24 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/sessions.py
src/web/auth.py

index eb7a2cfd453afb5314423334ae1c5567dcfac8ff..0ab736c8f25e1161f8236ffe29eaac82167dbbb1 100644 (file)
@@ -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)
index af89e7720a450a06dd4f0901e3da3e069786e639..60653895bfea2708e6577c7b1f7897695f557cff 100644 (file)
@@ -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")