Improved alerts for error handling login
This commit is contained in:
parent
88c6757bd3
commit
6ca7f0d31f
2 changed files with 14 additions and 3 deletions
|
@ -639,7 +639,11 @@ export const api: API = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
return { success: false, message: "Failed to login" };
|
return {
|
||||||
|
success: false,
|
||||||
|
data: `${response.status}`,
|
||||||
|
message: "Failed to login",
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
const data = (await response.json()) as { token: string }; // Update the type of 'data'
|
const data = (await response.json()) as { token: string }; // Update the type of 'data'
|
||||||
return { success: true, data: data.token };
|
return { success: true, data: data.token };
|
||||||
|
|
|
@ -46,8 +46,15 @@ function LoginCheck(props: {
|
||||||
console.error("Token was undefined");
|
console.error("Token was undefined");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error("Token could not be fetched/No such user");
|
if (response.data === "500") {
|
||||||
alert("Could not login, wrong username or password");
|
console.error(response.message);
|
||||||
|
alert("No connection/Error");
|
||||||
|
} else {
|
||||||
|
console.error(
|
||||||
|
"Token could not be fetched/No such user" + response.message,
|
||||||
|
);
|
||||||
|
alert("Incorrect login information");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|
Loading…
Reference in a new issue