🚀 release v3.0.0

This commit is contained in:
Amruth Pillai
2022-03-06 22:48:29 +01:00
parent 00505a9e5d
commit 9c1380f401
373 changed files with 12050 additions and 15783 deletions

View File

@ -1,66 +0,0 @@
import { Body, Controller, Delete, Get, HttpCode, Post, UseGuards } from '@nestjs/common';
import { User } from '@/decorators/user.decorator';
import { User as UserEntity } from '@/users/entities/user.entity';
import { AuthService } from './auth.service';
import { ForgotPasswordDto } from './dto/forgot-password.dto';
import { RegisterDto } from './dto/register.dto';
import { ResetPasswordDto } from './dto/reset-password.dto';
import { JwtAuthGuard } from './guards/jwt.guard';
import { LocalAuthGuard } from './guards/local.guard';
@Controller('auth')
export class AuthController {
constructor(private readonly authService: AuthService) {}
@UseGuards(JwtAuthGuard)
@Get()
authenticate(@User() user: UserEntity) {
return user;
}
@Post('google')
async loginWithGoogle(@Body('accessToken') googleAccessToken: string) {
const user = await this.authService.authenticateWithGoogle(googleAccessToken);
const accessToken = this.authService.getAccessToken(user.id);
return { user, accessToken };
}
@Post('register')
async register(@Body() registerDto: RegisterDto) {
const user = await this.authService.register(registerDto);
const accessToken = this.authService.getAccessToken(user.id);
return { user, accessToken };
}
@HttpCode(200)
@UseGuards(LocalAuthGuard)
@Post('login')
async login(@User() user: UserEntity) {
const accessToken = this.authService.getAccessToken(user.id);
return { user, accessToken };
}
@HttpCode(200)
@Post('forgot-password')
forgotPassword(@Body() forgotPasswordDto: ForgotPasswordDto) {
return this.authService.forgotPassword(forgotPasswordDto.email);
}
@HttpCode(200)
@Post('reset-password')
resetPassword(@Body() resetPasswordDto: ResetPasswordDto) {
return this.authService.resetPassword(resetPasswordDto);
}
@HttpCode(200)
@UseGuards(JwtAuthGuard)
@Delete()
async remove(@User('id') id: number) {
await this.authService.removeUser(id);
}
}