Skip to content

Admin cannot add a new role to himself #16748

Closed
@mvarblow

Description

Describe the bug

Admin cannot add a new role to himself (or remove a role from himself) unless he is a site owner.

Orchard Core version

2.0

To Reproduce

Steps to reproduce the behavior:

  1. Start with a fresh Orchard solution (empty app_data). Set up the site using the blog recipe and sqlite to keep it simple.
  2. Go to '/admin' panel and sign in using the admin account (e.g. the original admin from site setup).
  3. Edit the Administrator role, remove the "Site Owners Permission" permission, and click Save.
  4. Create a new user named 'admin2', grant it the Administrator role, and copy the password.
  5. Sign out, go back to the '/admin' panel, and sign in using the new admin2 username and password.
  6. Go to the Users page, edit the admin2 user account, grant another role (e.g. Contributor), and click Save.
  7. See the success notification.
  8. Edit your admin user account and see that the notification was a lie. Your user still has the same roles as before.
  9. Scratch your head and wonder what just happened.
  10. Curse and repeat step 6.

Expected behavior

Your user account should be updated to include the roles you selected (or to remove the ones you deselected) when you edited it. If the current behavior is as documented, I couldn't find the documentation. And it is incredibly confusing for the admin.

Editing your own roles is allowed for a site admin. I don't understand (and our clients don't understand) why this should not be allowed for other admins who are granted the permission to edit user role assignments. A safeguard against getting locked out of the site? I could understand that. But then why is it allowed for site owners? And isn't that why OrchardCore includes this check?

image

It seems that at a minimum, there should be a notification that the change of roles was blocked. The success message in this case is very confusing and I think makes this a bug. However, I think this check should be removed. It's confusing. It doesn't seem justified given that we already have user permissions to control who can change user roles. And there is already a sanity check to ensure that the only site admin hasn't removed their admin rights. If we wanted to do something like this, it should be done with a distinct permission (e.g. "Edit my own roles") not with the Site Owner permission.

(Possibly related to #8977. Also, it looks like there used to be a notification that you couldn't change your own roles but it was removed because it was appearing in a front-end user profile edit endpoint? I suspect it was unintentionally removed for this use case where the user is edited from the admin panel?)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions