From 9d0df6cfae831e1e564ab1c37cb5cc512f33fc42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Fri, 28 Oct 2022 14:42:09 +0200 Subject: [PATCH] small fix for client detecti --- server/src/uds/REST/methods/client.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/src/uds/REST/methods/client.py b/server/src/uds/REST/methods/client.py index a5a87f85..ffb09bae 100644 --- a/server/src/uds/REST/methods/client.py +++ b/server/src/uds/REST/methods/client.py @@ -46,6 +46,8 @@ from uds.core.util.config import GlobalConfig from uds.core.services.exceptions import ServiceNotReadyError from uds.core import VERSION as UDS_VERSION +if typing.TYPE_CHECKING: + from uds.models import UserService logger = logging.getLogger(__name__) @@ -53,6 +55,7 @@ CLIENT_VERSION = UDS_VERSION REQUIRED_CLIENT_VERSION = '3.5.0' + # Enclosed methods under /client path class Client(Handler): """ @@ -122,6 +125,7 @@ class Client(Handler): if len(self._args) == 1: # Simple test return Client.result(_('Correct')) + userService: typing.Optional['UserService'] = None try: ( ticket, @@ -180,9 +184,6 @@ class Client(Handler): ) password = cryptoManager().symDecrpyt(data['password'], scrambler) - # Set "accesedByClient" - userService.setProperty('accessedByClient', '1') - # userService.setConnectionSource(srcIp, hostname) # Store where we are accessing from so we can notify Service if not ip: raise ServiceNotReadyError() @@ -218,10 +219,6 @@ class Client(Handler): } ) except ServiceNotReadyError as e: - # Set that client has accesed userService - if e.userService: - e.userService.setProperty('accessedByClient', '1') - # Refresh ticket and make this retrayable TicketStore.revalidate( ticket, 20 @@ -232,3 +229,7 @@ class Client(Handler): except Exception as e: logger.exception("Exception") return Client.result(error=str(e)) + + finally: + if userService: + userService.setProperty('accessedByClient', '1')