Skip to content
Snippets Groups Projects
Commit e27318f9 authored by Arie Peterson's avatar Arie Peterson
Browse files

Show user roles in CLI

parent 4dacbed5
No related branches found
No related tags found
No related merge requests found
......@@ -116,13 +116,13 @@ cli.cli.add_command(app_cli)
@click.argument("app_slug")
@click.argument("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 app_slug: Slug name of the app, for example 'nextcloud'
: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
user = KratosUser.find_by_email(KRATOS_ADMIN, email)
......@@ -177,6 +177,14 @@ def show_user(email):
print(f"Updated: {user.updated_at}")
print(f"Created: {user.created_at}")
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:
print(f"User with email address '{email}' was not found")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment