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) {
|
||||
return { success: false, message: "Failed to login" };
|
||||
return {
|
||||
success: false,
|
||||
data: `${response.status}`,
|
||||
message: "Failed to login",
|
||||
};
|
||||
} else {
|
||||
const data = (await response.json()) as { token: string }; // Update the type of 'data'
|
||||
return { success: true, data: data.token };
|
||||
|
|
|
@ -46,8 +46,15 @@ function LoginCheck(props: {
|
|||
console.error("Token was undefined");
|
||||
}
|
||||
} else {
|
||||
console.error("Token could not be fetched/No such user");
|
||||
alert("Could not login, wrong username or password");
|
||||
if (response.data === "500") {
|
||||
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) => {
|
||||
|
|
Loading…
Reference in a new issue