测试token请求
This commit is contained in:
		
							parent
							
								
									ebc405f548
								
							
						
					
					
						commit
						8e044465d1
					
				| 
						 | 
					@ -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',
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue