chore: add user get profile and check validity route

This commit is contained in:
mahyargdz
2025-01-22 09:50:03 +03:30
parent 7431dad85f
commit 72b6cb35a0
39 changed files with 874 additions and 127 deletions
+29 -16
View File
@@ -1,41 +1,54 @@
import { Body, Controller, Post } from "@nestjs/common";
import { Body, Controller, HttpCode, HttpStatus, Post, UseGuards } from "@nestjs/common";
import { ApiOperation, ApiTags } from "@nestjs/swagger";
import { Throttle, ThrottlerGuard } from "@nestjs/throttler";
import { AuthService } from "./auth.service";
import { CompleteRegistrationDto } from "./DTO/complete-register.dto";
import { LoginPasswordDTO } from "./DTO/loginPassword.dto";
import { RequestOtpDto } from "./DTO/request-otp.dto";
import { VerifyOtpDto } from "./DTO/verify-otp.dto";
import { AuthService } from "./providers/auth.service";
import { AUTH_THROTTLE_LIMIT, AUTH_THROTTLE_TTL } from "../../common/constants";
@ApiTags("Auth")
@Controller("auth")
@Throttle({ default: { limit: AUTH_THROTTLE_LIMIT, ttl: AUTH_THROTTLE_TTL } })
@UseGuards(ThrottlerGuard)
export class AuthController {
constructor(private authService: AuthService) {}
@ApiOperation({ summary: "Initiate registration" })
@HttpCode(HttpStatus.OK)
@Post("register/initiate")
async register(@Body() registerDto: RequestOtpDto) {
register(@Body() registerDto: RequestOtpDto) {
return this.authService.initiateRegistration(registerDto);
}
@ApiOperation({ summary: "complete registration ==> step 2" })
@Post("register/complete")
async completeRegistration(@Body() completeRegistrationDto: CompleteRegistrationDto) {
completeRegistration(@Body() completeRegistrationDto: CompleteRegistrationDto) {
return this.authService.completeRegistration(completeRegistrationDto);
}
// @Post("login")
// async login(@Body() loginDto: LoginDto) {
// return this.authService.login(loginDto);
// }
@ApiOperation({ summary: "request to login with otp" })
@HttpCode(HttpStatus.OK)
@Post("otp/send")
sendOtp(@Body() requestOtpDto: RequestOtpDto) {
return this.authService.requestLoginOtp(requestOtpDto);
}
// @Post("otp/register/send")
// async sendOtp(@Body() sendOtpDto: RequestOtpDto) {
// return this.authService.requestRegisterOTP(sendOtpDto);
// }
@ApiOperation({ summary: "verify otp for login" })
@HttpCode(HttpStatus.OK)
@Post("otp/verify")
verifyOtp(@Body() verifyOtpDto: VerifyOtpDto) {
return this.authService.verifyLoginOtp(verifyOtpDto);
}
// @Post("otp/verify")
// async verifyOtp(@Body() verifyOtpDto: VerifyOtpDto) {
// return this.authService.verifyOtp(verifyOtpDto);
// }
@ApiOperation({ summary: "login with password" })
@HttpCode(HttpStatus.OK)
@Post("login/password")
loginWithPassword(@Body() loginPasswordDto: LoginPasswordDTO) {
return this.authService.loginWithPassword(loginPasswordDto);
}
// @Post("forgot-password")
// async forgotPassword(@Body() forgotPasswordDto: ForgotPasswordDto) {