From d9d3bc452c07f63eda080d989df879d7ab895b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Sat, 6 Aug 2022 20:19:23 +0200 Subject: [PATCH] fixed login/logout --- actor/src/udsactor/http/local.py | 2 +- actor/src/udsactor/service.py | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/actor/src/udsactor/http/local.py b/actor/src/udsactor/http/local.py index 77a023b6..f9b0c46f 100644 --- a/actor/src/udsactor/http/local.py +++ b/actor/src/udsactor/http/local.py @@ -42,7 +42,7 @@ class LocalProvider(handler.Handler): return result._asdict() def post_logout(self) -> typing.Any: - self._service.logout(self._params['username']) + self._service.logout(self._params['username'], self._params['session_type']) return 'ok' def post_ping(self) -> typing.Any: diff --git a/actor/src/udsactor/service.py b/actor/src/udsactor/service.py index 7c94acd7..8e7b62f0 100644 --- a/actor/src/udsactor/service.py +++ b/actor/src/udsactor/service.py @@ -465,7 +465,7 @@ class CommonService: # pylint: disable=too-many-instance-attributes # Now check if every registered client is already there (if logged in OFC) if self._loggedIn and not self._clientsPool.ping(): - self.logout('client_unavailable') + self.logout('client_unavailable', '') except Exception as e: logger.error('Exception on main service loop: %s', e) @@ -488,8 +488,6 @@ class CommonService: # pylint: disable=too-many-instance-attributes result = types.LoginResultInfoType( ip='', hostname='', dead_line=None, max_idle=None ) - self._loggedIn = True - master_token = None secret = None # If unmanaged, do initialization now, because we don't know before this @@ -515,16 +513,16 @@ class CommonService: # pylint: disable=too-many-instance-attributes secret, ) - script = platform.store.invokeScriptOnLogin() - if script: - script += f'{username} {sessionType or "unknown"} {self._cfg.actorType}' - self.execute(script, 'Logon') + if result.logged_in: + self._loggedIn = True + script = platform.store.invokeScriptOnLogin() + if script: + script += f'{username} {sessionType or "unknown"} {self._cfg.actorType}' + self.execute(script, 'Logon') return result - def logout(self, username: str, sessionType: typing.Optional[str] = None) -> None: - self._loggedIn = False - + def logout(self, username: str, sessionType: typing.Optional[str]) -> None: master_token = self._cfg.master_token # Own token will not be set if UDS did not assigned the initialized VM to an user @@ -546,6 +544,7 @@ class CommonService: # pylint: disable=too-many-instance-attributes logger.info('Logout from %s ignored as required by uds broker', username) return + self._loggedIn = False self.onLogout(username) if not self.isManaged():