gg
This commit is contained in:
@@ -3,6 +3,7 @@ import { PassportStrategy } from "@nestjs/passport";
|
||||
import { ExtractJwt, Strategy } from "passport-jwt";
|
||||
import { ConfigService } from "@nestjs/config";
|
||||
import { AuthService, JwtPayload } from "../auth.service";
|
||||
import { normalizeRole } from "../../../common/constants/roles";
|
||||
|
||||
@Injectable()
|
||||
export class JwtStrategy extends PassportStrategy(Strategy) {
|
||||
@@ -29,9 +30,13 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const normalizedRole = normalizeRole(payload.role);
|
||||
|
||||
return {
|
||||
...user,
|
||||
role: payload.role,
|
||||
role: normalizedRole,
|
||||
roles: normalizedRole ? [normalizedRole] : [],
|
||||
permissions: [],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user