From 0ef90ecc1edd23789d67d488fdd52a4f7bf8f45f Mon Sep 17 00:00:00 2001 From: Luka Radenovic Date: Fri, 15 Apr 2022 13:26:16 +0200 Subject: [PATCH] Fix setrole cli function --- cliapp/cliapp/cli.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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()