25 lines
604 B
TypeScript
25 lines
604 B
TypeScript
import { Controller, Get, Post, Request, UseGuards } from '@nestjs/common';
|
|
import { LocalAuthGuard } from './local-auth.guard';
|
|
import { AuthService } from './auth.service';
|
|
import { Public } from './public.decorator';
|
|
|
|
@Controller({
|
|
path: 'auth',
|
|
version: '1',
|
|
})
|
|
export class AuthController {
|
|
constructor(private authService: AuthService) {}
|
|
|
|
@Public()
|
|
@UseGuards(LocalAuthGuard)
|
|
@Post('login')
|
|
async login(@Request() req) {
|
|
return this.authService.login(req.user);
|
|
}
|
|
|
|
@Get('profile')
|
|
getProfile(@Request() req) {
|
|
return this.authService.getProfile(req.user.userId);
|
|
}
|
|
}
|