forked from shaba/openuds
added "accesedByClient" property so we can check, from web, if local plugin is installed....
This commit is contained in:
parent
87c2ea8add
commit
2b5543905a
@ -38,7 +38,7 @@ from django.utils.translation import ugettext as _
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from uds.REST import Handler
|
from uds.REST import Handler
|
||||||
from uds.REST import RequestError
|
from uds.REST import RequestError
|
||||||
from uds.models import TicketStore
|
from uds.models import TicketStore, user
|
||||||
from uds.models import User
|
from uds.models import User
|
||||||
from uds.web.util import errors
|
from uds.web.util import errors
|
||||||
from uds.core.managers import cryptoManager, userServiceManager
|
from uds.core.managers import cryptoManager, userServiceManager
|
||||||
@ -147,6 +147,10 @@ class Client(Handler):
|
|||||||
# userService.setConnectionSource(srcIp, hostname) # Store where we are accessing from so we can notify Service
|
# userService.setConnectionSource(srcIp, hostname) # Store where we are accessing from so we can notify Service
|
||||||
if not ip:
|
if not ip:
|
||||||
raise ServiceNotReadyError
|
raise ServiceNotReadyError
|
||||||
|
|
||||||
|
# Set "accesedByClient"
|
||||||
|
userService.setProperty('accessedByClient', '1')
|
||||||
|
|
||||||
transportScript, signature, params = transportInstance.getEncodedTransportScript(userService, transport, ip, self._request.os, self._request.user, password, self._request)
|
transportScript, signature, params = transportInstance.getEncodedTransportScript(userService, transport, ip, self._request.os, self._request.user, password, self._request)
|
||||||
|
|
||||||
logger.debug('Signature: %s', signature)
|
logger.debug('Signature: %s', signature)
|
||||||
|
@ -535,7 +535,7 @@ class UserService(UUIDModel): # pylint: disable=too-many-public-methods
|
|||||||
dct[v.name] = v.value
|
dct[v.name] = v.value
|
||||||
return dct
|
return dct
|
||||||
|
|
||||||
def setProperty(self, propName: str, propValue: typing.Optional[str]) -> None:
|
def setProperty(self, propName: str, propValue: typing.Optional[str] = None) -> None:
|
||||||
prop, _ = self.properties.get_or_create(name=propName)
|
prop, _ = self.properties.get_or_create(name=propName)
|
||||||
prop.value = propValue or ''
|
prop.value = propValue or ''
|
||||||
prop.save()
|
prop.save()
|
||||||
|
@ -163,6 +163,9 @@ def userServiceEnabler(
|
|||||||
'password': password,
|
'password': password,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Ensure "client access" is removed on enable action...
|
||||||
|
userService.setProperty('accessedByClient', '0')
|
||||||
|
|
||||||
ticket = TicketStore.create(data)
|
ticket = TicketStore.create(data)
|
||||||
url = html.udsLink(request, ticket, scrambler)
|
url = html.udsLink(request, ticket, scrambler)
|
||||||
except ServiceNotReadyError as e:
|
except ServiceNotReadyError as e:
|
||||||
@ -198,9 +201,14 @@ def userServiceStatus(
|
|||||||
request: 'ExtendedHttpRequestWithUser', idService: str, idTransport: str
|
request: 'ExtendedHttpRequestWithUser', idService: str, idTransport: str
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
'''
|
'''
|
||||||
Returns 'running' if not ready, or 'ready' if ready (as json)
|
Returns;
|
||||||
|
'running' if not ready
|
||||||
|
'ready' if is ready but not accesed by client
|
||||||
|
'accessed' if ready and accesed by UDS client
|
||||||
|
Note:
|
||||||
'''
|
'''
|
||||||
ip: typing.Union[str, None, bool]
|
ip: typing.Union[str, None, bool]
|
||||||
|
userService = None
|
||||||
try:
|
try:
|
||||||
(
|
(
|
||||||
ip,
|
ip,
|
||||||
@ -217,7 +225,11 @@ def userServiceStatus(
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
ip = False
|
ip = False
|
||||||
|
|
||||||
status = 'running' if ip is None else 'error' if ip is False else 'ready'
|
ready = 'ready'
|
||||||
|
if userService and userService.getProperty('accessedByClient') != '0':
|
||||||
|
ready = 'accessed'
|
||||||
|
|
||||||
|
status = 'running' if ip is None else 'error' if ip is False else ready
|
||||||
|
|
||||||
return HttpResponse(
|
return HttpResponse(
|
||||||
json.dumps({'status': status}), content_type='application/json'
|
json.dumps({'status': status}), content_type='application/json'
|
||||||
|
Loading…
Reference in New Issue
Block a user