mirror of
https://git.meshkee.com/BaloutPastry/backend.git
synced 2026-08-11 22:31:00 +04:30
74 lines
2.1 KiB
TypeScript
74 lines
2.1 KiB
TypeScript
import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
|
|
import type { AuthUser } from './auth.types';
|
|
import { AuthService } from './auth.service';
|
|
import { CurrentUser } from './decorators/current-user.decorator';
|
|
import { CellNumberDto } from './dto/cell-number.dto';
|
|
import { ForgotPasswordResetDto } from './dto/forgot-password-reset.dto';
|
|
import { LoginDto } from './dto/login.dto';
|
|
import { OtpVerifyDto } from './dto/otp-verify.dto';
|
|
import { RefreshTokenDto } from './dto/refresh-token.dto';
|
|
import { RegisterSendCodeDto } from './dto/register-send-code.dto';
|
|
import { RegisterVerifyDto } from './dto/register-verify.dto';
|
|
import { JwtAuthGuard } from './guards/jwt-auth.guard';
|
|
|
|
@Controller('auth')
|
|
export class AuthController {
|
|
constructor(private readonly auth: AuthService) {}
|
|
|
|
@Post('login')
|
|
login(@Body() dto: LoginDto) {
|
|
return this.auth.login(dto);
|
|
}
|
|
|
|
@Post('login/send-code')
|
|
loginSendCode(@Body() dto: CellNumberDto) {
|
|
return this.auth.loginSendCode(dto);
|
|
}
|
|
|
|
@Post('login/verify')
|
|
loginVerify(@Body() dto: OtpVerifyDto) {
|
|
return this.auth.loginVerify(dto);
|
|
}
|
|
|
|
@Post('forgot-password/send-code')
|
|
forgotPasswordSendCode(@Body() dto: CellNumberDto) {
|
|
return this.auth.forgotPasswordSendCode(dto);
|
|
}
|
|
|
|
@Post('forgot-password/verify')
|
|
forgotPasswordVerify(@Body() dto: OtpVerifyDto) {
|
|
return this.auth.forgotPasswordVerify(dto);
|
|
}
|
|
|
|
@Post('forgot-password/reset')
|
|
forgotPasswordReset(@Body() dto: ForgotPasswordResetDto) {
|
|
return this.auth.forgotPasswordReset(dto);
|
|
}
|
|
|
|
@Post('register/send-code')
|
|
registerSendCode(@Body() dto: RegisterSendCodeDto) {
|
|
return this.auth.registerSendCode(dto);
|
|
}
|
|
|
|
@Post('register/verify')
|
|
registerVerify(@Body() dto: RegisterVerifyDto) {
|
|
return this.auth.registerVerify(dto);
|
|
}
|
|
|
|
@Post('refresh')
|
|
refresh(@Body() dto: RefreshTokenDto) {
|
|
return this.auth.refresh(dto.refreshToken);
|
|
}
|
|
|
|
@Post('logout')
|
|
logout(@Body() dto: RefreshTokenDto) {
|
|
return this.auth.logout(dto.refreshToken);
|
|
}
|
|
|
|
@Get('me')
|
|
@UseGuards(JwtAuthGuard)
|
|
me(@CurrentUser() user: AuthUser) {
|
|
return this.auth.me(user);
|
|
}
|
|
}
|