mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-08 23:49:08 +00:00
FIX: permissions array on user findOneById
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
BatchCreateUserReq,
|
||||
CreateUserReq,
|
||||
Hierarchy,
|
||||
IUserByCustomer,
|
||||
SetUserRolesReq,
|
||||
UpdateUserReq,
|
||||
} from './dtos/entities';
|
||||
@@ -77,11 +78,21 @@ export class UsersService implements OnModuleInit {
|
||||
};
|
||||
}
|
||||
|
||||
async findOneById(id: string) {
|
||||
async findOneById(id: string): Promise<{ user: IUserByCustomer }> {
|
||||
const { user } = await lastValueFrom(
|
||||
this.usersClientService.UserFindOneById({ id }),
|
||||
);
|
||||
return { user: this.adjustUsersPayload([user])[0] };
|
||||
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;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
async createUser(req: CreateUserReq, meta?: Metadata) {
|
||||
|
||||
Reference in New Issue
Block a user