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