Skip to content

Commit

Permalink
chore: improve error message when its DB related
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Nov 11, 2024
1 parent 55bd461 commit f7b96e6
Showing 1 changed file with 33 additions and 23 deletions.
56 changes: 33 additions & 23 deletions apps/client/pages/auth/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,43 @@ export default function Login({}) {
const [url, setUrl] = useState("");

async function postData() {
await fetch(`/api/v1/auth/login`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email, password }),
})
.then((res) => res.json())
.then(async (res) => {
if (res.user) {
setCookie("session", res.token);
if (res.user.external_user) {
router.push("/portal");
} else {
if (res.user.firstLogin) {
router.push("/onboarding");
try {
await fetch(`/api/v1/auth/login`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email, password }),
})
.then((res) => res.json())
.then(async (res) => {
if (res.user) {
setCookie("session", res.token);
if (res.user.external_user) {
router.push("/portal");
} else {
router.push("/");
if (res.user.firstLogin) {
router.push("/onboarding");
} else {
router.push("/");
}
}
} else {
toast({
variant: "destructive",
title: "Error",
description:
"There was an error logging in, please try again. If this issue persists, please contact support via the discord.",
});
}
} else {
toast({
variant: "destructive",
title: "Error",
description:
"There was an error logging in, please try again. If this issue persists, please contact support via the discord.",
});
}
});
} catch (error) {
console.error(error);
toast({
variant: "destructive",
title: "Database Error",
description:
"This is an issue with the database, please check the docker logs or contact support via discord.",
});
}
}

async function oidcLogin() {
Expand Down

0 comments on commit f7b96e6

Please sign in to comment.