Added Joi for schema validation, tidied up envs

This commit is contained in:
SepehrYahyaee
2026-05-30 10:37:23 +03:30
parent 10df869efb
commit 6ac0bf060e
12 changed files with 176 additions and 59 deletions

View File

@@ -31,7 +31,7 @@ export class ClaimAccessGuard implements CanActivate {
try {
const payload = await this.jwtService.verifyAsync(token, {
secret: `${process.env.SECRET}`,
secret: `${process.env.JWT_SECRET}`,
});
// Allow users to pass through (they will be checked by service methods)
@@ -81,7 +81,10 @@ export class ClaimAccessGuard implements CanActivate {
throw new UnauthorizedException("Invalid role");
} catch (error) {
if (error instanceof ForbiddenException || error instanceof UnauthorizedException) {
if (
error instanceof ForbiddenException ||
error instanceof UnauthorizedException
) {
throw error;
}
throw new UnauthorizedException();
@@ -124,4 +127,3 @@ export class ClaimAccessGuard implements CanActivate {
return type === "Bearer" ? token : undefined;
}
}