Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions invenio_accounts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ def roles_add(user, role):
raise click.UsageError("Cannot find user.")
if role is None:
raise click.UsageError("Cannot find role.")
if not role.is_managed:
click.secho(
'Role "{0}" is externally managed. Cannot perform CLI actions on it.'.format(
role
),
fg="red",
)
return
if _datastore.add_role_to_user(user, role):
click.secho(
'Role "{0}" added to user "{1}" ' "successfully.".format(role, user),
Expand All @@ -126,6 +134,14 @@ def roles_remove(user, role):
raise click.UsageError("Cannot find user.")
if role is None:
raise click.UsageError("Cannot find role.")
if not role.is_managed:
click.secho(
'Role "{0}" is externally managed. Cannot perform CLI actions on it.'.format(
role
),
fg="red",
)
return
if _datastore.remove_role_from_user(user, role):
click.secho(
'Role "{0}" removed from user "{1}" ' "successfully.".format(role, user),
Expand Down
Loading