improvement: error handeling structure changed and unified all across the app. user no longer sees inappropriate messages.
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import {
|
||||
CanActivate,
|
||||
ExecutionContext,
|
||||
HttpStatus,
|
||||
Injectable,
|
||||
UnauthorizedException,
|
||||
} from '@nestjs/common';
|
||||
import { PrismaService } from '../../../prisma/prisma.service';
|
||||
import { assertClinicOrganization } from '../../common/organization-type';
|
||||
import { AppException, ErrorCode } from '../errors';
|
||||
|
||||
@Injectable()
|
||||
export class ClinicOrgGuard implements CanActivate {
|
||||
@@ -16,7 +17,7 @@ export class ClinicOrgGuard implements CanActivate {
|
||||
const organizationId = request.user?.organizationId;
|
||||
|
||||
if (!organizationId) {
|
||||
throw new UnauthorizedException('Organization is not selected');
|
||||
throw new AppException(ErrorCode.AUTH_ORG_NOT_SELECTED, HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
await assertClinicOrganization(this.prisma, organizationId);
|
||||
|
||||
Reference in New Issue
Block a user