changeset 1599:197350e8bf3b default tip @

pages(g): fix guest session data: Following https://repos.goffi.org/libervia-web/rev/86c7a3a625d5, new session are now started on connection, as a result, guest data were lost on connection. This patch fixes it by storing those data after the connection.
author Goffi <goffi@goffi.org>
date Tue, 05 Mar 2024 16:40:25 +0100
parents 86c7a3a625d5
children
files libervia/web/pages/g/page_meta.py
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/web/pages/g/page_meta.py	Fri Feb 23 13:35:24 2024 +0100
+++ b/libervia/web/pages/g/page_meta.py	Tue Mar 05 16:40:25 2024 +0100
@@ -21,6 +21,7 @@
         invitation_id = self.next_path(request)
     except IndexError:
         self.page_error(request)
+        return
 
     web_session, guest_session = self.host.get_session_data(
         request, session_iface.IWebSession, session_iface.IWebGuestSession
@@ -28,6 +29,7 @@
     current_id = guest_session.id
 
     if current_id is not None and current_id != invitation_id:
+        # we are already in a guest session, but not the one specified in URL, we reset id
         log.info(
             _(
                 "killing guest session [{old_id}] because it is connecting with an other ID [{new_id}]"
@@ -59,9 +61,7 @@
             data = await self.host.bridge_call("invitation_get", invitation_id)
         except Exception:
             self.page_error(request, C.HTTP_FORBIDDEN)
-        else:
-            guest_session.id = invitation_id
-            guest_session.data = data
+            return
     else:
         data = guest_session.data
 
@@ -77,6 +77,13 @@
             # FIXME: no good error code correspond
             #        maybe use a custom one?
             self.page_error(request, code=C.HTTP_SERVICE_UNAVAILABLE)
+        else:
+            # a new session is created, we need to store guest session data
+            __, guest_session = self.host.get_session_data(
+                request, session_iface.IWebSession, session_iface.IWebGuestSession
+            )
+            guest_session.id = invitation_id
+            guest_session.data = data
 
         log.info(
             _(