Skip to content

Commit c0cd2bc

Browse files
committed
refactor: update error handling in PaidFeatureGuard for unauthorized access
1 parent f2a00ec commit c0cd2bc

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

backend/src/guards/paid-feature.guard.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { BadRequestException, CanActivate, ExecutionContext, Inject, Injectable } from '@nestjs/common';
1+
import {
2+
BadRequestException,
3+
CanActivate,
4+
ExecutionContext,
5+
Inject,
6+
Injectable,
7+
UnauthorizedException,
8+
} from '@nestjs/common';
29
import { Observable } from 'rxjs';
310
import { IRequestWithCognitoInfo } from '../authorization/cognito-decoded.interface.js';
411
import { IGlobalDatabaseContext } from '../common/application/global-database-context.interface.js';
@@ -23,7 +30,7 @@ export class PaidFeatureGuard implements CanActivate {
2330
const request: IRequestWithCognitoInfo = context.switchToHttp().getRequest();
2431
const userId: string | undefined = request.decoded.sub;
2532
if (!userId) {
26-
reject(new BadRequestException(Messages.COMPANY_ID_MISSING));
33+
reject(new UnauthorizedException(Messages.DONT_HAVE_PERMISSIONS));
2734
return;
2835
}
2936
let companyId: string | undefined = request.params?.companyId || request.params?.slug;

0 commit comments

Comments
 (0)