Commit 5f00878d authored by mingyard's avatar mingyard

feat:auth catch error

parent 235fe4dd
import { UseGuards } from '@nestjs/common'; import { UseFilters, UseGuards } from '@nestjs/common';
import { AuthGuard } from '../../controller/auth/auth.guard'; import { AuthGuard } from '../../controller/auth/auth.guard';
import { ApiBearerAuth } from '@nestjs/swagger'; import { ApiBearerAuth } from '@nestjs/swagger';
import { ApiExceptionsFilter } from '../filter/api.exception.filter';
/** /**
* 认证 装饰器 * 认证 装饰器
...@@ -11,6 +12,7 @@ export const Auth = () => { ...@@ -11,6 +12,7 @@ export const Auth = () => {
// 装饰器由上至下求值,由下至上执行 // 装饰器由上至下求值,由下至上执行
const decorators: any[] = []; const decorators: any[] = [];
decorators.push(UseGuards(AuthGuard)); decorators.push(UseGuards(AuthGuard));
decorators.push(UseFilters(ApiExceptionsFilter));
decorators.push(ApiBearerAuth()); decorators.push(ApiBearerAuth());
decorators.reverse().forEach((f) => f(...args)); decorators.reverse().forEach((f) => f(...args));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment