add permitons to new users

This commit is contained in:
Cayo Puigdefabregas 2022-11-24 17:54:25 +01:00
parent 9d8fb6b04a
commit 88b13961fe
2 changed files with 18 additions and 0 deletions

View File

@ -95,3 +95,4 @@ class DevicehubConfig(Config):
MAIL_USE_TLS = config('MAIL_USE_TLS', True) MAIL_USE_TLS = config('MAIL_USE_TLS', True)
MAIL_DEFAULT_SENDER = config('MAIL_DEFAULT_SENDER', '') MAIL_DEFAULT_SENDER = config('MAIL_DEFAULT_SENDER', '')
API_DLT = config('API_DLT', None) API_DLT = config('API_DLT', None)
KEYUSER1 = config('KEYUSER1', None)

View File

@ -3,6 +3,7 @@ from uuid import uuid4
from citext import CIText from citext import CIText
from flask import current_app as app from flask import current_app as app
from flask import session
from flask_login import UserMixin from flask_login import UserMixin
from sqlalchemy import BigInteger, Boolean, Column, Sequence from sqlalchemy import BigInteger, Boolean, Column, Sequence
from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.dialects.postgresql import UUID
@ -127,6 +128,22 @@ class User(UserMixin, Thing):
data = json.dumps(data) data = json.dumps(data)
self.api_keys_dlt = encrypt(password, data) self.api_keys_dlt = encrypt(password, data)
def allow_permitions(self, password):
if 'trublo' not in app.blueprints.keys():
return
from ereuseapi.methods import API
target_user = session.get('token_dlt', '.').split(".")[0]
keyUser1 = app.config.get('KEYUSER1')
api_dlt = app.config.get('API_DLT')
if not keyUser1 or api_dlt:
return
apiUser1 = API(api_dlt, keyUser1, "ethereum")
apiUser1.issue_credential("Operator", target_user)
class UserInventory(db.Model): class UserInventory(db.Model):
"""Relationship between users and their inventories.""" """Relationship between users and their inventories."""