Skip to content

Commit

Permalink
feat: handle 302 redirect
Browse files Browse the repository at this point in the history
Signed-off-by: hanifdwyputras <hanifdwyputrasembiring@gmail.com>
  • Loading branch information
hansputera committed Jun 3, 2023
1 parent ec975fd commit 754cb67
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions src/components/forms/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const LoginForm = () => {
session.reset();
}
}
}, [savedToken, router]);
}, [savedToken, router, session]);

return (
<div>
Expand All @@ -59,7 +59,19 @@ export const LoginForm = () => {
'Content-Type': 'application/json',
},
method: 'POST',
}).then(r => r.json()).then(res => {
}).then(r => {
setData({
isError: false,
});
if (r.status === 302) {
setData({
isError: true,
message: 'Invalid credentials',
});
actions.setSubmitting(false);
}
return r.json();
}).then(res => {
if (res.errors || res.error) {
setData({
isError: true,
Expand Down

0 comments on commit 754cb67

Please sign in to comment.