This commit is contained in:
2025-11-16 11:07:14 +03:30
parent fae765e05a
commit d605303e52
15 changed files with 331 additions and 17 deletions
@@ -19,7 +19,7 @@ export class AdminAuthController {
@ApiResponse({ status: 201, description: 'OTP requested successfully' })
@ApiResponse({ status: 400, description: 'Invalid mobile number' })
otpRequest(@Body() dto: RequestOtpDto) {
return this.authService.requestOtp(dto);
return this.authService.requestOtpAdmin(dto);
}
@Post('otp/verify')
@@ -28,7 +28,7 @@ export class AdminAuthController {
@ApiResponse({ status: 200, description: 'OTP verified successfully' })
@ApiResponse({ status: 400, description: 'Invalid OTP or expired' })
otpVerify(@Body() dto: VerifyOtpDto) {
return this.authService.verifyOtp(dto.phone, dto.slug, dto.otp); // assuming dto has `otp` property
return this.authService.verifyOtpAdmin(dto.phone, dto.slug, dto.otp); // assuming dto has `otp` property
}
// @Post('admin/otp/request')
+1 -1
View File
@@ -71,7 +71,7 @@ export class AuthService {
}
async verifyOtpAdmin(phone: string, slug: string, code: string) {
const cachedCode = await this.cacheService.get(`otp:${slug}:${phone}`);
const cachedCode = await this.cacheService.get(`otp-admin:${slug}:${phone}`);
if (!cachedCode) throw new BadRequestException('OTP expired or not found');
if (cachedCode !== code) throw new BadRequestException('Invalid OTP');
+4 -4
View File
@@ -10,10 +10,10 @@ import { AuthMessage, UserMessage } from '../../../common/enums/message.enum';
import { RefreshToken } from '../../users/entities/refresh-token.entity';
import { User } from '../../users/entities/user.entity';
import { IAdminTokenPayload, ITokenPayload } from '../interfaces/IToken-payload';
import { Restaurant } from 'src/modules/restaurants/entities/restaurant.entity';
import { RestRepository } from 'src/modules/restaurants/repositories/rest.repository';
import { Admin } from 'src/modules/admin/entities/admin.entity';
import { CacheService } from 'src/modules/utils/cache.service';
import { Restaurant } from '../../restaurants/entities/restaurant.entity';
import { RestRepository } from '../../restaurants/repositories/rest.repository';
import { Admin } from '../../admin/entities/admin.entity';
import { CacheService } from '../../utils/cache.service';
@Injectable()
export class TokensService {