diff --git a/cliapp/cliapp/cli.py b/cliapp/cliapp/cli.py index b3f1acb..d39b70e 100644 --- a/cliapp/cliapp/cli.py +++ b/cliapp/cliapp/cli.py @@ -11,10 +11,12 @@ import ory_kratos_client from flask import current_app from flask.cli import AppGroup from ory_kratos_client.api import v0alpha2_api as kratos_api +from sqlalchemy import func from config import * from helpers import KratosUser from cliapp import cli +from areas.roles import Role from areas.apps import AppRole, App from database import db @@ -136,10 +138,12 @@ def setrole(email, app_slug, role): if role_obj: db.session.delete(role_obj) + role = Role.query.filter(func.lower(Role.name) == func.lower(role)).first() + obj = AppRole() obj.user_id = user.uuid obj.app_id = app_obj.id - obj.role = role + obj.role_id = role.id if role else None db.session.add(obj) db.session.commit()