测试token请求

This commit is contained in:
Jeremy Yin 2019-07-09 21:39:22 +08:00
parent ebc405f548
commit 8e044465d1
1 changed files with 12 additions and 1 deletions

View File

@ -1,6 +1,8 @@
import { Controller, Post, Body } from '@nestjs/common'; import { Controller, Post, Body, Get, UseGuards } from '@nestjs/common';
import { AuthService } from './auth.service'; import { AuthService } from './auth.service';
import { LoginDto } from './login.dto'; import { LoginDto } from './login.dto';
import { AuthGuard } from '@nestjs/passport';
import { User } from '../../core/decorators/user.decorator';
@Controller('auth') @Controller('auth')
export class AuthController { export class AuthController {
@ -13,4 +15,13 @@ export class AuthController {
return await this.authService.login(data) return await this.authService.login(data)
} }
@Get('test')
@UseGuards(AuthGuard())
async authTest(@User() user) {
console.log('user: ', user)
return {
message: 'ok',
}
}
} }