diff --git a/components/SignIn.tsx b/components/SignIn.tsx
index bb69b8d..d0bea0b 100644
--- a/components/SignIn.tsx
+++ b/components/SignIn.tsx
@@ -12,6 +12,7 @@ export function SignIn() {
const [csrfToken, setCsrfToken] = useState("");
const [loading, setLoading] = useState(false);
+ const [errorState, setErrorState] = useState(false);
const router = useRouter();
@@ -36,16 +37,23 @@ export function SignIn() {
`password=${encodeURIComponent(formData.get('password') as string)}`,
].join('&');
- await fetch("/api/auth/callback/credentials", {
+ const res = await fetch("/api/auth/callback/credentials", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: urlEncodedData,
});
+
+ if (res.url.includes("error")) {
+ setLoading(false)
+ setErrorState(true)
+ } else {
+ setLoading(false)
+ setErrorState(false)
+ }
router.push("/");
router.refresh();
- setLoading(false)
};
return (
@@ -56,6 +64,11 @@ export function SignIn() {