Roles being stripped from users when saved if user has no access to roles field

Created on 9 June 2022, about 2 years ago
Updated 19 December 2023, 6 months ago

Problem/Motivation

When a user who has access to edit roles with role delegation edits a user on a form, where the roles field is disabled (not displayed), then on save it will strip all the roles from the user account.

Note this issue has a different root problem than πŸ› Roles being stripped from users when saved Active .

Steps to reproduce

1. Create a role where you allow to assign roles with the role delegation module.
2. Create/assign the previously created role to a user.
3. Remove from the default display form mode the "User name and password" field which should remove the user, password and role fields from the user edit form OR in hook field access give access false to the ['account']['roles'] field.
4. Login with the user from point 2. Edit your own profile and save it.
5. Now you are only a simple user, without any roles. (except authenticated)

Proposed resolution

As looking at the code there are many different ways to handle this. Either by allowing the roles_change to be configured on the display form mode so the admin can disable it from that place, or automatically handle when the original role field is not accessible, either by setting the correct default value after form submits or somewhere else to skip the saving process.

Remaining tasks

-
- test
- review
- commit

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium golddragon007

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024