Created
June 3, 2020 05:40
-
-
Save onwuvic/4423ca0b370460870a287f4f6d1d761e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller, Body, Post, UseGuards, Request } from '@nestjs/common'; | |
import { AuthGuard } from '@nestjs/passport'; | |
import { AuthService } from './auth.service'; | |
import { UserDto } from '../users/dto/user.dto'; | |
@Controller('auth') | |
export class AuthController { | |
constructor(private authService: AuthService) {} | |
@UseGuards(AuthGuard('local')) | |
@Post('login') | |
async login(@Request() req) { | |
return await this.authService.login(req.user); | |
} | |
@Post('signup') | |
async signUp(@Body() user: UserDto) { | |
return await this.authService.create(user); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment