Show user roles in CLI
This commit is contained in:
parent
4dacbed57d
commit
e27318f93d
1 changed files with 10 additions and 2 deletions
|
@ -116,13 +116,13 @@ cli.cli.add_command(app_cli)
|
||||||
@click.argument("app_slug")
|
@click.argument("app_slug")
|
||||||
@click.argument("role")
|
@click.argument("role")
|
||||||
def setrole(email, app_slug, role):
|
def setrole(email, app_slug, role):
|
||||||
"""Set role for a sure
|
"""Set role for a user
|
||||||
:param email: Email address of user to assign role
|
:param email: Email address of user to assign role
|
||||||
:param app_slug: Slug name of the app, for example 'nextcloud'
|
:param app_slug: Slug name of the app, for example 'nextcloud'
|
||||||
:param role: Role to assign. currently only 'admin', 'user'
|
:param role: Role to assign. currently only 'admin', 'user'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
current_app.logger.info(f"Assiging role {role} to {email} for app {app_slug}")
|
current_app.logger.info(f"Assigning role {role} to {email} for app {app_slug}")
|
||||||
|
|
||||||
# Find user
|
# Find user
|
||||||
user = KratosUser.find_by_email(KRATOS_ADMIN, email)
|
user = KratosUser.find_by_email(KRATOS_ADMIN, email)
|
||||||
|
@ -177,6 +177,14 @@ def show_user(email):
|
||||||
print(f"Updated: {user.updated_at}")
|
print(f"Updated: {user.updated_at}")
|
||||||
print(f"Created: {user.created_at}")
|
print(f"Created: {user.created_at}")
|
||||||
print(f"State: {user.state}")
|
print(f"State: {user.state}")
|
||||||
|
print(f"Roles:")
|
||||||
|
results = db.session.query(AppRole, Role).join(App, Role)\
|
||||||
|
.add_entity(App).add_entity(Role)\
|
||||||
|
.filter(AppRole.user_id == user.uuid)
|
||||||
|
for entry in results:
|
||||||
|
app = entry[-2]
|
||||||
|
role = entry[-1]
|
||||||
|
print(f" {role.name: >9} on {app.name}")
|
||||||
else:
|
else:
|
||||||
print(f"User with email address '{email}' was not found")
|
print(f"User with email address '{email}' was not found")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue