(self, data, sendResponse)
| 21 | #REQUESTS |
| 22 | |
| 23 | def getAccessKeys(self, data, sendResponse): |
| 24 | publicKey = email = accessKey = None |
| 25 | |
| 26 | if 'email' in data: |
| 27 | email = data['email'] |
| 28 | |
| 29 | if 'accessKey' in data: |
| 30 | accessKey = data['accessKey'] |
| 31 | |
| 32 | userLogged = settings().get(["cloudSlicer", "loggedUser"]) |
| 33 | #### |
| 34 | # - nobody logged: None |
| 35 | # - any log: email |
| 36 | |
| 37 | if email and accessKey:#somebody is logged in the remote client |
| 38 | if userLogged:#Somebody logged in Astrobox |
| 39 | if userLogged == email:#I am the user logged |
| 40 | online = networkManager().isOnline() |
| 41 | |
| 42 | if online: |
| 43 | publicKey = astroprintCloud().get_public_key(email, accessKey) |
| 44 | |
| 45 | if not publicKey: |
| 46 | self._logger.error('error getting public key', exc_info = True) |
| 47 | sendResponse('error_getting_public_key',True) |
| 48 | return |
| 49 | |
| 50 | else: |
| 51 | user = userManager.findUser(email) |
| 52 | if user.get_private_key() != accessKey: |
| 53 | self._logger.error('incorrect logged user', exc_info = True) |
| 54 | sendResponse('incorrect_logged_user',True) |
| 55 | return |
| 56 | |
| 57 | else:#I am NOT the logged user |
| 58 | self._logger.error('incorrect logged user', exc_info = True) |
| 59 | sendResponse('incorrect_logged_user',True) |
| 60 | return |
| 61 | |
| 62 | else:#nodody is logged in the remote client |
| 63 | if userLogged: |
| 64 | self._logger.error('any user logged', exc_info = True) |
| 65 | sendResponse('no_user_logged',True) |
| 66 | return |
| 67 | |
| 68 | sendResponse({ |
| 69 | 'api_key': UI_API_KEY, |
| 70 | 'ws_token': create_ws_token(publicKey) |
| 71 | }) |
nothing calls this directly
no test coverage detected