comment set rols for users
This commit is contained in:
parent
5c02b424c1
commit
95700e7ba4
|
@ -8,12 +8,13 @@ def register_user(email, password, rols="Operator"):
|
|||
# rols = 'Issuer, Operator, Witness, Verifier'
|
||||
user = User.query.filter_by(email=email).one()
|
||||
|
||||
token_dlt = user.set_new_dlt_keys(password)
|
||||
result = user.allow_permitions(api_token=token_dlt, rols=rols)
|
||||
rols = user.get_rols(token_dlt=token_dlt)
|
||||
rols = [k for k, v in rols]
|
||||
user.rols_dlt = json.dumps(rols)
|
||||
# token_dlt = user.set_new_dlt_keys(password)
|
||||
# result = user.allow_permitions(api_token=token_dlt, rols=rols)
|
||||
# rols = user.get_rols(token_dlt=token_dlt)
|
||||
# rols = [k for k, v in rols]
|
||||
# user.rols_dlt = json.dumps(rols)
|
||||
|
||||
db.session.commit()
|
||||
# db.session.commit()
|
||||
|
||||
return result, rols
|
||||
# return result, rols
|
||||
return
|
||||
|
|
|
@ -5,5 +5,5 @@ from ereuse_devicehub.resources.user.models import User
|
|||
def set_dlt_user(email, password):
|
||||
u = User.query.filter_by(email=email).one()
|
||||
api_token = u.set_new_dlt_keys(password)
|
||||
u.allow_permitions(api_token)
|
||||
# u.allow_permitions(api_token)
|
||||
db.session.commit()
|
||||
|
|
|
@ -140,22 +140,25 @@ class User(UserMixin, Thing):
|
|||
self.api_keys_dlt = encrypt(password, data)
|
||||
|
||||
def allow_permitions(self, api_token=None, rols="Operator"):
|
||||
if 'dpp' not in app.blueprints.keys():
|
||||
# Is discontinued over IOTA branch
|
||||
return
|
||||
|
||||
if not api_token:
|
||||
api_token = session.get('token_dlt', '.')
|
||||
target_user = api_token.split(".")[0]
|
||||
keyUser1 = app.config.get('API_DLT_TOKEN')
|
||||
api_dlt = app.config.get('API_DLT')
|
||||
if not keyUser1 or not api_dlt:
|
||||
return
|
||||
# if 'dpp' not in app.blueprints.keys():
|
||||
# return
|
||||
|
||||
apiUser1 = API(api_dlt, keyUser1, "ethereum")
|
||||
# if not api_token:
|
||||
# api_token = session.get('token_dlt', '.')
|
||||
# target_user = api_token.split(".")[0]
|
||||
# keyUser1 = app.config.get('API_DLT_TOKEN')
|
||||
# api_dlt = app.config.get('API_DLT')
|
||||
# if not keyUser1 or not api_dlt:
|
||||
# return
|
||||
|
||||
for rol in rols.split(","):
|
||||
result = apiUser1.issue_credential(rol.strip(), target_user)
|
||||
return result
|
||||
# apiUser1 = API(api_dlt, keyUser1, "ethereum")
|
||||
|
||||
# for rol in rols.split(","):
|
||||
# result = apiUser1.issue_credential(rol.strip(), target_user)
|
||||
# return result
|
||||
|
||||
def get_rols_dlt(self):
|
||||
return json.loads(self.rols_dlt)
|
||||
|
|
Reference in New Issue