up
This commit is contained in:
@@ -9,6 +9,7 @@ import { AdminRepository } from 'src/modules/admin/repositories/admin.repository
|
||||
import { AdminLoginTransformer } from '../transformers/admin-login.transformer';
|
||||
import { UserLoginTransformer } from '../transformers/user-login.transformer';
|
||||
import { OtpService } from './otp.service';
|
||||
import { normalizePhoneToLocal } from 'src/modules/util/phone.util';
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
@@ -25,7 +26,7 @@ export class AuthService {
|
||||
}
|
||||
|
||||
async requestOtp(dto: RequestOtpDto, isAdmin: boolean) {
|
||||
const { phone } = dto;
|
||||
const phone = normalizePhoneToLocal(dto.phone);
|
||||
|
||||
if (isAdmin) {
|
||||
await this.valdateAdmin(phone)
|
||||
@@ -41,6 +42,7 @@ export class AuthService {
|
||||
}
|
||||
|
||||
async verifyOtp(phone: string, code: string) {
|
||||
phone = normalizePhoneToLocal(phone);
|
||||
|
||||
const cachedCode = await this.otpService.get(phone);
|
||||
if (!cachedCode) throw new BadRequestException('OTP expired or not found');
|
||||
@@ -63,6 +65,7 @@ export class AuthService {
|
||||
}
|
||||
|
||||
async verifyOtpAdmin(phone: string, code: string) {
|
||||
phone = normalizePhoneToLocal(phone);
|
||||
|
||||
const cachedCode = await this.otpService.get(phone);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user