diff --git a/backend/src/auth/auth.service.ts b/backend/src/auth/auth.service.ts index f6ad9d2..8b66838 100644 --- a/backend/src/auth/auth.service.ts +++ b/backend/src/auth/auth.service.ts @@ -207,6 +207,7 @@ export class AuthService { const accessToken = await this.jwtService.generateJwt({ sub: user.uuid, username: user.username, + role: user.role, }); return { diff --git a/backend/src/users/users.service.ts b/backend/src/users/users.service.ts index 82fa7ad..a2e8ac3 100644 --- a/backend/src/users/users.service.ts +++ b/backend/src/users/users.service.ts @@ -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) { diff --git a/frontend/src/components/ui/scroll-area.tsx b/frontend/src/components/ui/scroll-area.tsx index e1bc7d6..ce015d0 100644 --- a/frontend/src/components/ui/scroll-area.tsx +++ b/frontend/src/components/ui/scroll-area.tsx @@ -8,8 +8,11 @@ import { cn } from "@/lib/utils"; function ScrollArea({ className, children, + viewportRef, ...props -}: React.ComponentProps) { +}: React.ComponentProps & { + viewportRef?: React.Ref; +}) { return ( {children}