Production code

feat : 2 factor authentication , OTP service , Session timeout
This commit is contained in:
2025-10-15 11:50:25 +05:30
parent 569e31bf12
commit ad19f0cb4c
7 changed files with 62 additions and 40 deletions

View File

@@ -19,7 +19,7 @@ export default function ValidateUser() {
const headerRef = useRef<HTMLHeadingElement>(null);
const validUsers = [
{ cif: "11111111111", mobile: "6297421727" },
{ cif: "11111111111", mobile: "7890544528" },
{ cif: "30022497139", mobile: "6230573848" },
{ cif: "11122233344", mobile: "9998887776" },
];

View File

@@ -16,8 +16,8 @@ interface SendOtpPayload {
}
function getStoredMobileNumber(): string | null {
// const mobileNumber = localStorage.getItem('remitter_mobile_no');
const mobileNumber = "6297421727";
const mobileNumber = localStorage.getItem('remitter_mobile_no');
// const mobileNumber = "7890544527";
if (!mobileNumber) {
notifications.show({
title: 'Missing Mobile Number',

View File

@@ -13,7 +13,6 @@ import dynamic from 'next/dynamic';
import { generateCaptcha } from '@/app/captcha';
import { IconRefresh, IconShieldLockFilled } from "@tabler/icons-react";
import dayjs from "dayjs";
import { IconTrash } from "@tabler/icons-react";
import { fetchAndStoreUserName } from "../_util/userdetails";
@@ -47,8 +46,8 @@ export default function Login() {
}
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: mobile });
// await sendOtp({ type: 'LOGIN_OTP', username: CIF, mobileNumber: '7890544527' });
notifications.show({
color: "orange",
title: "OTP Required",
@@ -69,8 +68,8 @@ export default function Login() {
async function handleVerifyOtp(mobile?: string) {
try {
if (mobile) {
// await verifyLoginOtp(otp, mobile);
await verifyLoginOtp(otp, '6297421727');
await verifyLoginOtp(otp, mobile);
// await verifyLoginOtp(otp, '7890544527');
return true;
}
} catch {
@@ -102,7 +101,6 @@ export default function Login() {
}, []);
const regenerateCaptcha = () => {
// setCaptcha(generateCaptcha());
const loadCaptcha = async () => {
const newCaptcha = await generateCaptcha();
setCaptcha(newCaptcha);