feat: enhance user service with role assignment and frontend scroll-area ref support

- Updated `users.service.ts` to assign user roles dynamically based on RBAC.
- Enhanced JWT generation to include the user's role in `auth.service.ts`.
- Added `viewportRef` prop support to `ScrollArea` component in the frontend for improved flexibility.
This commit is contained in:
Mathis HERRIOT
2026-01-29 14:43:01 +01:00
parent 209711195b
commit 27f8c7148a
3 changed files with 32 additions and 3 deletions

View File

@@ -45,7 +45,19 @@ export class UsersService {
}
async findByEmailHash(emailHash: string) {
return await this.usersRepository.findByEmailHash(emailHash);
const user = await this.usersRepository.findByEmailHash(emailHash);
if (!user) return null;
const roles = await this.rbacService.getUserRoles(user.uuid);
return {
...user,
role: roles.includes("admin")
? "admin"
: roles.includes("moderator")
? "moderator"
: "user",
roles,
};
}
async findOneWithPrivateData(uuid: string) {
@@ -95,7 +107,19 @@ export class UsersService {
}
async findOne(uuid: string) {
return await this.usersRepository.findOne(uuid);
const user = await this.usersRepository.findOne(uuid);
if (!user) return null;
const roles = await this.rbacService.getUserRoles(user.uuid);
return {
...user,
role: roles.includes("admin")
? "admin"
: roles.includes("moderator")
? "moderator"
: "user",
roles,
};
}
async update(uuid: string, data: UpdateUserDto) {