()
| 307 | |
| 308 | @app.route("/accessKeys", methods=["POST"]) |
| 309 | def getAccessKeys(): |
| 310 | from astroprint.cloud import astroprintCloud |
| 311 | |
| 312 | publicKey = None |
| 313 | email = request.values.get('email', None) |
| 314 | accessKey = request.values.get('accessKey', None) |
| 315 | |
| 316 | userLogged = settings().get(["cloudSlicer", "loggedUser"]) |
| 317 | #### |
| 318 | # - nobody logged: None |
| 319 | # - any log: email |
| 320 | |
| 321 | if email and accessKey:#somebody is logged in the remote client |
| 322 | if userLogged:#Somebody logged in Astrobox |
| 323 | if userLogged == email:#I am the user logged |
| 324 | online = networkManager().isOnline() |
| 325 | |
| 326 | if online: |
| 327 | publicKey = astroprintCloud().get_public_key(email, accessKey) |
| 328 | |
| 329 | if not publicKey: |
| 330 | abort(403) |
| 331 | |
| 332 | else: |
| 333 | user = userManager.findUser(email) |
| 334 | if user.get_private_key() != accessKey: |
| 335 | abort(403) |
| 336 | |
| 337 | else:#I am NOT the logged user |
| 338 | abort(403) |
| 339 | |
| 340 | else:#nodody is logged in the remote client |
| 341 | if userLogged: |
| 342 | abort(401) |
| 343 | |
| 344 | return Response( |
| 345 | json.dumps({ |
| 346 | 'api_key': UI_API_KEY, |
| 347 | 'ws_token': create_ws_token(publicKey) |
| 348 | }), |
| 349 | mimetype= 'application/json', |
| 350 | headers= { |
| 351 | 'Access-Control-Allow-Origin': '*' |
| 352 | } if settings().getBoolean(['api', 'allowCrossOrigin']) else None |
| 353 | ) |
| 354 | |
| 355 | |
| 356 | @identity_loaded.connect_via(app) |
nothing calls this directly
no test coverage detected