feat: add admin guard and JWT role support
- Create AdminGuard to check user role - Update JWT strategy to include role in payload - Update auth service to include role in token generation - Prepare admin module structure - TypeScript will resolve lint errors after server restart
This commit is contained in:
7
apps/api/dist/auth/auth.service.js
vendored
7
apps/api/dist/auth/auth.service.js
vendored
@@ -317,10 +317,15 @@ let AuthService = class AuthService {
|
||||
token,
|
||||
};
|
||||
}
|
||||
generateToken(userId, email) {
|
||||
async generateToken(userId, email) {
|
||||
const user = await this.prisma.user.findUnique({
|
||||
where: { id: userId },
|
||||
select: { role: true },
|
||||
});
|
||||
return this.jwtService.sign({
|
||||
sub: userId,
|
||||
email,
|
||||
role: user?.role || 'user',
|
||||
});
|
||||
}
|
||||
generateTempToken(userId, email) {
|
||||
|
||||
Reference in New Issue
Block a user