diff libervia/pages/login/page_meta.py @ 1504:409d10211b20

server, browser: dynamic pages refactoring: dynamic pages has been reworked, to change the initial basic implementation. Pages are now dynamic by default, and a websocket is established by the first connected page of a session. The socket is used to transmit bridge signals, and then the signal is broadcasted to other tabs using broadcast channel. If the connecting tab is closed, an other one is chosen. Some tests are made to retry connecting in case of problem, and sometimes reload the pages (e.g. if profile is connected). Signals (or other data) are cached during reconnection phase, to avoid lost of data. All previous partial rendering mechanism have been removed, chat page is temporarily not working anymore, but will be eventually redone (one of the goal of this work is to have proper chat).
author Goffi <goffi@goffi.org>
date Wed, 01 Mar 2023 18:02:44 +0100
parents 6a35167a4e2c
children ce879da7fcf7
line wrap: on
line diff
--- a/libervia/pages/login/page_meta.py	Wed Mar 01 17:55:25 2023 +0100
+++ b/libervia/pages/login/page_meta.py	Wed Mar 01 18:02:44 2023 +0100
@@ -54,8 +54,7 @@
     return C.POST_NO_CONFIRM
 
 
-@defer.inlineCallbacks
-def on_data_post(self, request):
+async def on_data_post(self, request):
     profile = self.getProfile(request)
     type_ = self.getPostedData(request, "type")
     if type_ == "disconnect":
@@ -64,25 +63,25 @@
             self.pageError(request, C.HTTP_BAD_REQUEST)
         else:
             self.host.purgeSession(request)
-            defer.returnValue(C.POST_NO_CONFIRM)
+            return C.POST_NO_CONFIRM
     elif type_ == "login":
         login, password = self.getPostedData(request, ("login", "password"))
         try:
-            status = yield self.host.connect(request, login, password)
+            status = await self.host.connect(request, login, password)
         except exceptions.ProfileUnknownError:
             # the profile doesn't exist, we return the same error as for invalid password
             # to avoid bruteforcing valid profiles
             log.warning(f"login tentative with invalid profile: {login!r}")
-            defer.returnValue(login_error(self, request, C.PROFILE_AUTH_ERROR))
+            return login_error(self, request, C.PROFILE_AUTH_ERROR)
         except ValueError as e:
             message = str(e)
             if message in (C.XMPP_AUTH_ERROR, C.PROFILE_AUTH_ERROR):
-                defer.returnValue(login_error(self, request, message))
+                return login_error(self, request, message)
             else:
                 # this error was not expected!
                 raise e
         except exceptions.TimeOutError:
-            defer.returnValue(login_error(self, request, C.NO_REPLY))
+            return login_error(self, request, C.NO_REPLY)
         else:
             if status in (C.PROFILE_LOGGED, C.PROFILE_LOGGED_EXT_JID, C.SESSION_ACTIVE):
                 # Profile has been logged correctly