fix: stfc remove roles bug - #1605
Merged
Merged
Conversation
ellen-wright
requested review from
a team,
Bhaswati1148,
ChongJiaChua,
deepaksftc and
mutambaraf
and removed request for
a team,
Bhaswati1148 and
ChongJiaChua
June 24, 2026 14:10
deepaksftc
approved these changes
Jun 24, 2026
mutambaraf
reviewed
Jun 24, 2026
Comment on lines
+478
to
+480
| async removeUserRoles(id: number): Promise<void> { | ||
| return; | ||
| } |
Contributor
There was a problem hiding this comment.
We are not mocking any thing here
Comment on lines
+529
to
+531
| async removeUserRoles(id: number): Promise<void> { | ||
| throw new Error('Method not implemented.'); | ||
| } |
Contributor
There was a problem hiding this comment.
We may need to pass this to the super class or implement it.
|
|
||
| if (newRolesToAssign.length > 0) { | ||
| if (newRolesToAssign.length == 0) { | ||
| postgresUserDataSource.removeUserRoles(id); |
Contributor
There was a problem hiding this comment.
We may need await here
| } | ||
|
|
||
| async removeUserRoles(id: number): Promise<void> { | ||
| return database.transaction(async (trx) => { |
Contributor
There was a problem hiding this comment.
We may be missing await
|
|
||
| async removeUserRoles(id: number): Promise<void> { | ||
| return database.transaction(async (trx) => { | ||
| await trx<RoleUserRecord>('role_user').where('user_id', id).del(); |
Contributor
There was a problem hiding this comment.
This may leave some one with out any assigned role do not we need to leave at least the user role
Contributor
Author
There was a problem hiding this comment.
This will only remove the roles assigned in the role)user table all UOWS assigned roles will still be there and we give everyone at least one role from UOWS right?
YufanKambang
approved these changes
Jun 24, 2026
mutambaraf
approved these changes
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
refs: #UserOfficeProject/issue-tracker#1610
Fixes bug that stopped the removal of the all UOS given roles.
Now when removing a role if it is the last role given in UOS and not from STFC UOWS then all UOS roles are removed from the role_user table for that user and only roles from UOWS are left.
Motivation and Context
When wanting to remove all roles given in the UI and not from UOWS there was a bug where the role would not be deleted as it was the last roles associated with that user in the role_user table, however an STFC user will always have roles given by UOWS and therefore can have all UOS given roles removed without error.
How Has This Been Tested
Fixes
Changes
Depends on
Tests included/Docs Updated?