feat: Trim OTP input and update verification logic in host and user services
This commit is contained in:
@@ -413,6 +413,8 @@ export class UserService {
|
||||
}
|
||||
|
||||
async verifyHostOtp(mobileNumber: string, otp: string): Promise<boolean> {
|
||||
const trimmedOtp = (otp || '').toString().trim();
|
||||
|
||||
const user = await this.prisma.user.findFirst({
|
||||
where: { mobileNumber: mobileNumber, isActive: true },
|
||||
select: {
|
||||
@@ -440,7 +442,7 @@ export class UserService {
|
||||
throw new ApiError(400, 'OTP has expired.');
|
||||
}
|
||||
|
||||
const isMatch = await bcrypt.compare(otp, userOtp.otpCode);
|
||||
const isMatch = await bcrypt.compare(trimmedOtp, userOtp.otpCode);
|
||||
|
||||
if (!isMatch) {
|
||||
throw new ApiError(400, 'Invalid OTP.');
|
||||
|
||||
Reference in New Issue
Block a user