fix: do not remove default role

This commit is contained in:
Methapon2001 2024-04-22 11:18:10 +07:00
parent 2e5fba0b07
commit 503505757d

View file

@ -370,7 +370,16 @@ export class UserController extends Controller {
if (!resultAddRole) {
throw new Error("Failed. Cannot set user's role.");
} 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;