From e7cf069a33891879430b778cd8a225f21a606fc5 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 24 Nov 2022 18:00:16 +0100 Subject: [PATCH] add api_token --- ereuse_devicehub/resources/user/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/resources/user/models.py b/ereuse_devicehub/resources/user/models.py index 7373cb3b..d0287b94 100644 --- a/ereuse_devicehub/resources/user/models.py +++ b/ereuse_devicehub/resources/user/models.py @@ -109,6 +109,7 @@ class User(UserMixin, Thing): data = register_user(api_dlt) data = json.dumps(data) self.api_keys_dlt = encrypt(password, data) + return data.get('data', {}).get('api_token') def get_dlt_keys(self, password): if 'trublo' not in app.blueprints.keys(): @@ -128,13 +129,15 @@ class User(UserMixin, Thing): data = json.dumps(data) self.api_keys_dlt = encrypt(password, data) - def allow_permitions(self, password): + def allow_permitions(self, api_token=None): if 'trublo' not in app.blueprints.keys(): return from ereuseapi.methods import API - target_user = session.get('token_dlt', '.').split(".")[0] + if not api_token: + api_token = session.get('token_dlt', '.') + target_user = api_token.split(".")[0] keyUser1 = app.config.get('KEYUSER1') api_dlt = app.config.get('API_DLT') if not keyUser1 or api_dlt: