feat : Otp verification Feature active.
This commit is contained in:
@@ -35,30 +35,29 @@ export default function Login() {
|
||||
const [mobile, setMobile] = useState("");
|
||||
|
||||
async function handleSendOtp(mobile?: string) {
|
||||
// console.log("hi mobile", mobile);
|
||||
if (!mobile) {
|
||||
notifications.show({
|
||||
title: 'Error',
|
||||
message: 'Mobile number not found.Contact to administrator',
|
||||
message: 'Mobile number not found. Contact administrator.',
|
||||
color: 'red',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
// console.log(CIF);
|
||||
await sendOtp({ type: 'LOGIN_OTP', username: CIF, mobileNumber: mobile });
|
||||
// await sendOtp({ type: 'LOGIN_OTP', username: CIF, mobileNumber: '7890544527' });
|
||||
// await sendOtp({ type: 'LOGIN_OTP', username: CIF, mobileNumber: "7890544527" });
|
||||
notifications.show({
|
||||
color: "orange",
|
||||
title: "OTP Required",
|
||||
message: "OTP sent to your registered mobile number",
|
||||
color: 'orange',
|
||||
title: 'OTP Required',
|
||||
message: 'OTP sent to your registered mobile number.',
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (err: any) {
|
||||
} catch (err: any) {
|
||||
notifications.show({
|
||||
title: 'Error',
|
||||
message: `${err.error}.SMS vendor facing some issue.Please try again later.` || 'Send OTP failed.Please try again later.',
|
||||
message: err?.message || 'Send OTP failed. Please try again later.',
|
||||
color: 'red',
|
||||
});
|
||||
return false;
|
||||
@@ -72,11 +71,18 @@ export default function Login() {
|
||||
// await verifyLoginOtp(otp, '7890544527');
|
||||
return true;
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
catch (err: any) {
|
||||
notifications.show({
|
||||
title: `${err.message}`,
|
||||
message: 'OTP verification failed. Please try again later.',
|
||||
color: 'red',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const loadCaptcha = async () => {
|
||||
const newCaptcha = await generateCaptcha();
|
||||
@@ -193,15 +199,8 @@ export default function Login() {
|
||||
setMobile(data.mobile);
|
||||
setOtpRequired(true);
|
||||
setButtonLabel("Verify OTP");
|
||||
|
||||
|
||||
const otpSent = await handleSendOtp(data.mobile);
|
||||
// if (otpSent) {
|
||||
// notifications.show({
|
||||
// color: "orange",
|
||||
// title: "OTP Required",
|
||||
// message: "OTP sent to your registered mobile number",
|
||||
// });
|
||||
// }
|
||||
setIsLogging(false);
|
||||
return;
|
||||
}
|
||||
@@ -271,17 +270,12 @@ export default function Login() {
|
||||
|
||||
const verified = await handleVerifyOtp(mobile);
|
||||
if (!verified) {
|
||||
notifications.show({
|
||||
title: "Invalid OTP",
|
||||
message: "The OTP entered does not match",
|
||||
color: "red",
|
||||
});
|
||||
setIsLogging(false);
|
||||
return;
|
||||
}
|
||||
|
||||
notifications.show({
|
||||
color: "green",
|
||||
color: "Blue",
|
||||
title: "OTP Verified",
|
||||
message: "Please click Login to continue",
|
||||
});
|
||||
@@ -583,6 +577,7 @@ export default function Login() {
|
||||
label="Enter OTP"
|
||||
placeholder="Enter OTP"
|
||||
value={otp}
|
||||
maxLength={6}
|
||||
onChange={(e) => setOtp(e.currentTarget.value)}
|
||||
withAsterisk
|
||||
style={{ flex: 1 }}
|
||||
|
||||
Reference in New Issue
Block a user