2021-07-08 07:39:07 +00:00
|
|
|
import { Controller, Get, Request, Post, UseGuards } from '@nestjs/common';
|
2021-07-11 05:39:55 +00:00
|
|
|
import { JwtAuthGuard } from '../modules/auth/jwt-auth.guard';
|
|
|
|
|
import { AuthService } from '../services/auth.service';
|
2021-07-08 05:40:27 +00:00
|
|
|
|
|
|
|
|
@Controller()
|
|
|
|
|
export class AppController {
|
2021-07-08 07:39:07 +00:00
|
|
|
constructor(private authService: AuthService) {}
|
2021-07-08 05:40:27 +00:00
|
|
|
|
2021-07-09 10:52:03 +00:00
|
|
|
@Post('authenticate')
|
2021-07-08 07:39:07 +00:00
|
|
|
async login(@Request() req) {
|
|
|
|
|
return this.authService.login(req.body);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-19 05:42:16 +00:00
|
|
|
@Post('signup')
|
|
|
|
|
async signup(@Request() req) {
|
|
|
|
|
return this.authService.signup(req.body);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-26 16:02:47 +00:00
|
|
|
@Post('/forgot_password')
|
|
|
|
|
async forgotPassword(@Request() req) {
|
|
|
|
|
await this.authService.forgotPassword(req.body.email);
|
|
|
|
|
return {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Post('/reset_password')
|
|
|
|
|
async resetPassword(@Request() req) {
|
|
|
|
|
const { token, password } = req.body;
|
|
|
|
|
await this.authService.resetPassword(token, password);
|
|
|
|
|
return {}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-08 05:40:27 +00:00
|
|
|
}
|