fix: do not remove default role
This commit is contained in:
parent
2e5fba0b07
commit
503505757d
1 changed files with 10 additions and 1 deletions
|
|
@ -370,7 +370,16 @@ export class UserController extends Controller {
|
||||||
if (!resultAddRole) {
|
if (!resultAddRole) {
|
||||||
throw new Error("Failed. Cannot set user's role.");
|
throw new Error("Failed. Cannot set user's role.");
|
||||||
} else {
|
} else {
|
||||||
if (Array.isArray(currentRole)) await removeUserRoles(userId, currentRole);
|
if (Array.isArray(currentRole))
|
||||||
|
await removeUserRoles(
|
||||||
|
userId,
|
||||||
|
currentRole.filter(
|
||||||
|
(a) =>
|
||||||
|
!["uma_authorization", "offline_access", "default-roles"].some((b) =>
|
||||||
|
a.name.includes(b),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
userRole = role.name;
|
userRole = role.name;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue