mirror of
https://git.meshkee.com/BaloutPastry/backend.git
synced 2026-08-12 06:40:59 +04:30
Add SMS OTP auth, discounts, customer orders, and category slugs.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
58380ab81d
commit
d09eca8702
@@ -1,13 +1,15 @@
|
||||
import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
|
||||
import { UserRole } from '@prisma/client';
|
||||
import type { AuthUser } from './auth.types';
|
||||
import { AuthService } from './auth.service';
|
||||
import { CurrentUser } from './decorators/current-user.decorator';
|
||||
import { Roles } from './decorators/roles.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';
|
||||
import { RolesGuard } from './guards/roles.guard';
|
||||
|
||||
@Controller('auth')
|
||||
export class AuthController {
|
||||
@@ -18,6 +20,41 @@ export class AuthController {
|
||||
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);
|
||||
@@ -29,8 +66,7 @@ export class AuthController {
|
||||
}
|
||||
|
||||
@Get('me')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles(UserRole.admin, UserRole.superAdmin)
|
||||
@UseGuards(JwtAuthGuard)
|
||||
me(@CurrentUser() user: AuthUser) {
|
||||
return this.auth.me(user);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user