Fix login redirect: push router immediately and skip SWR revalidation

After login, explicitly navigate to destination instead of relying
on useEffect. Also skip SWR revalidation to prevent a race where the
re-fetch overrides the mutated user data.

Made-with: Cursor
This commit is contained in:
Talal Sharabi
2026-03-15 20:02:40 +04:00
parent 1544215008
commit e27d8231e9

View File

@@ -82,7 +82,8 @@ export default function Login({ destination = "/" }: { destination?: string }) {
toast.success("You have been logged in!", {
toastId: "login-successful",
});
mutateUser(response.data);
mutateUser(response.data, { revalidate: false });
router.push(destination);
})
.catch((e) => {
if (e.response.status === 401) {