Skip to content

Instantly share code, notes, and snippets.

@onwuvic
Created June 3, 2020 05:40
Show Gist options
  • Save onwuvic/4423ca0b370460870a287f4f6d1d761e to your computer and use it in GitHub Desktop.
Save onwuvic/4423ca0b370460870a287f4f6d1d761e to your computer and use it in GitHub Desktop.
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