mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-30 23:09:07 +00:00
FIX: new function to get all user permissions
This commit is contained in:
@@ -85,13 +85,16 @@ export class UsersService implements OnModuleInit {
|
||||
const res: { user: IUserByCustomer } = {
|
||||
user: this.adjustUsersPayload([user])[0],
|
||||
};
|
||||
if (res.user.roles?.length) {
|
||||
const allPermissions = res.user.roles.flatMap((r) => r.permissions);
|
||||
const distinctPermissions = Array.from(
|
||||
new Set(allPermissions.map((p) => p.claim)),
|
||||
);
|
||||
res.user.permissions = distinctPermissions;
|
||||
}
|
||||
const { permissions } = await lastValueFrom(
|
||||
this.usersClientService.GetUserPermissions({ id }),
|
||||
).catch((error) => {
|
||||
this.logger.error('UsersService.findOneById - GetUserPermissions', {
|
||||
error,
|
||||
});
|
||||
const permissions: string[] = [];
|
||||
return { permissions };
|
||||
});
|
||||
res.user.permissions = permissions;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user