refactor: Update source code with the NPCI and CBS API
This commit is contained in:
@@ -84,39 +84,62 @@ export default function Login() {
|
||||
});
|
||||
return;
|
||||
}
|
||||
const response = await fetch('api/auth/login', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
customerNo: CIF,
|
||||
password: psw,
|
||||
}),
|
||||
});
|
||||
const data = await response.json();
|
||||
setIsLogging(true);
|
||||
if (response.ok) {
|
||||
try {
|
||||
const response = await fetch('api/auth/login', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
customerNo: CIF,
|
||||
password: psw,
|
||||
}),
|
||||
});
|
||||
if (!response.ok) {
|
||||
notifications.show({
|
||||
withBorder: true,
|
||||
color: "red",
|
||||
title: "Error",
|
||||
message: "Internal Server Error",
|
||||
autoClose: 5000,
|
||||
});
|
||||
return;
|
||||
}
|
||||
const data = await response.json();
|
||||
console.log(data);
|
||||
const token = data.token;
|
||||
localStorage.setItem("access_token", token);
|
||||
if (data.FirstTimeLogin === true) {
|
||||
router.push("/SetPassword")
|
||||
setIsLogging(true);
|
||||
if (response.ok) {
|
||||
console.log(data);
|
||||
const token = data.token;
|
||||
localStorage.setItem("access_token", token);
|
||||
if (data.FirstTimeLogin === true) {
|
||||
router.push("/SetPassword")
|
||||
}
|
||||
else {
|
||||
router.push("/home");
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
router.push("/home");
|
||||
setIsLogging(false);
|
||||
notifications.show({
|
||||
withBorder: true,
|
||||
color: "red",
|
||||
title: "Wrong User Id or Password",
|
||||
message: "Wrong User Id or Password",
|
||||
autoClose: 5000,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
setIsLogging(false);
|
||||
catch (error: any) {
|
||||
notifications.show({
|
||||
withBorder: true,
|
||||
color: "red",
|
||||
title: "Wrong User Id or Password",
|
||||
message: "Wrong User Id or Password",
|
||||
title: "Error",
|
||||
message: "Internal Server Error,Please try again Later",
|
||||
autoClose: 5000,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
useEffect(() => {
|
||||
|
Reference in New Issue
Block a user