feat : user can login with user name..

fix: username should be one special  character and one alphabet.
This commit is contained in:
2025-10-25 18:54:14 +05:30
parent 2eec1b2e30
commit 3f1bbf1a4c
4 changed files with 54 additions and 24 deletions

View File

@@ -45,8 +45,8 @@ export default function Login() {
}
try {
// await sendOtp({ type: 'LOGIN_OTP', username: CIF, mobileNumber: mobile });
await sendOtp({ type: 'LOGIN_OTP', username: CIF, mobileNumber: "6297421727" });
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',
@@ -67,8 +67,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;
}
}
@@ -124,14 +124,15 @@ export default function Login() {
try {
// --- Validation (before any API call) ---
if (!otpRequired && !otpVerified) {
const onlyDigit = /^\d{11}$/;
// const onlyDigit = /^\d{11}$/;
const onlyDigit = /^[A-Za-z0-9@_]{5,11}$/;
if (!onlyDigit.test(CIF)) {
notifications.show({
withBorder: true,
color: "red",
title: "Invalid UserId",
message: "UserID must be 11 digit",
message: "The User ID or Username must contain 5 to 11 alphanumeric characters.",
autoClose: 5000,
});
setIsLogging(false);
@@ -178,6 +179,7 @@ export default function Login() {
// --- LOGIN API FLOW ---
if (!otpRequired || otpVerified) {
const isNumeric = /^\d+$/.test(CIF);
const response = await fetch("api/auth/login", {
method: "POST",
headers: {
@@ -185,7 +187,8 @@ export default function Login() {
"X-Login-Type": "IB",
},
body: JSON.stringify({
customerNo: CIF,
customerNo: isNumeric ? CIF : null,
userName: isNumeric ? null : CIF,
password: psw,
otp: otp,
}),
@@ -522,14 +525,15 @@ export default function Login() {
/>
</div>
<Box w={{ base: "100%", md: "45%" }} p="lg">
<Card shadow="md" padding="xl" radius="md" style={{ maxWidth: 550, height: '70vh' }}>
<Card shadow="md" padding="xl" radius="md" style={{ maxWidth: 550, height: '70vh', justifyContent: 'space-between' }} >
<form onSubmit={handleLogin}>
<TextInput
label="User ID"
placeholder="Enter your CIF No"
label="User ID / User Name"
placeholder="Enter your CIF No / User Name"
value={CIF}
onInput={(e) => {
const input = e.currentTarget.value.replace(/\D/g, "");
// const input = e.currentTarget.value.replace(/\D/g, "");
const input = e.currentTarget.value.replace(/[^A-Za-z0-9@_]/g, "");
if (input.length <= 11) SetCIF(input);
}}
withAsterisk
@@ -609,10 +613,17 @@ export default function Login() {
)}
<Button type="submit" fullWidth mt="md" loading={isLogging} disabled={isLogging}>
<Button type="submit" fullWidth mt="sm" loading={isLogging} disabled={isLogging}>
{isLogging ? "Processing..." : buttonLabel}
</Button>
<Box mt="xs">
<Text size="sm">
<Text component="span" c="red" fw={600}>Note: </Text>
<Text component="span" c="black">
Existing users logging in to the new Internet Banking for the first time should use their CIF number to avoid login issues.
</Text>
</Text>
</Box>
</form>
</Card>
</Box>