Skip to content

Commit

Permalink
Merge pull request #808 from autaut03/autaut03-fix/forbiddenNotHttpEx…
Browse files Browse the repository at this point in the history
…ception

bugfix(@nestjs/core): use ForbiddenException instead of HttpException
  • Loading branch information
kamilmysliwiec committed Jun 25, 2018
2 parents be6d90a + 7143d3b commit a6ab849
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/core/helpers/external-context-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { InterceptorsContextCreator } from './../interceptors/interceptors-conte
import { InterceptorsConsumer } from './../interceptors/interceptors-consumer';
import { Controller } from '@nestjs/common/interfaces';
import { FORBIDDEN_MESSAGE } from '../guards/constants';
import { HttpStatus, HttpException } from '@nestjs/common';
import { ForbiddenException } from '@nestjs/common';
import { Module } from './../injector/module';
import { ModulesContainer } from './../injector/modules-container';

Expand Down Expand Up @@ -38,7 +38,7 @@ export class ExternalContextCreator {
callback,
);
if (!canActivate) {
throw new HttpException(FORBIDDEN_MESSAGE, HttpStatus.FORBIDDEN);
throw new ForbiddenException(FORBIDDEN_MESSAGE);
}
const handler = () => callback.apply(instance, args);
return await this.interceptorsConsumer.intercept(
Expand Down
5 changes: 2 additions & 3 deletions packages/core/router/router-execution-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import { PipesConsumer } from './../pipes/pipes-consumer';
import {
ParamData,
PipeTransform,
HttpStatus,
RequestMethod,
HttpException,
ForbiddenException,
HttpServer,
} from '@nestjs/common';
import { GuardsContextCreator } from '../guards/guards-context-creator';
Expand Down Expand Up @@ -238,7 +237,7 @@ export class RouterExecutionContext {
callback,
);
if (!canActivate) {
throw new HttpException(FORBIDDEN_MESSAGE, HttpStatus.FORBIDDEN);
throw new ForbiddenException(FORBIDDEN_MESSAGE);
}
};
return guards.length ? canActivateFn : null;
Expand Down

0 comments on commit a6ab849

Please sign in to comment.