diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-29 14:29:29 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-29 14:29:29 +0700 |
| commit | 1d606fe88f97f87e32a58b1b187a71f40c70169c (patch) | |
| tree | 3045839e7e9362f1b851d182614f6ed3ae04af80 /src/lib/auth | |
| parent | ac230a35f325cc47e89fd5d635847536f2dd9b44 (diff) | |
blog detail
Diffstat (limited to 'src/lib/auth')
| -rw-r--r-- | src/lib/auth/components/IsAuth.jsx | 4 | ||||
| -rw-r--r-- | src/lib/auth/hooks/useLogin.js | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/auth/components/IsAuth.jsx b/src/lib/auth/components/IsAuth.jsx index 1cfd3172..a32e648c 100644 --- a/src/lib/auth/components/IsAuth.jsx +++ b/src/lib/auth/components/IsAuth.jsx @@ -7,8 +7,8 @@ const IsAuth = ({ children }) => { const [response, setResponse] = useState(<></>) useEffect(() => { - if (!getAuth()) { - router.replace('/login') + if (!getAuth() && router.pathname != '/login') { + router.replace(`/login?next=${router.asPath}`) } else { setResponse(children) } diff --git a/src/lib/auth/hooks/useLogin.js b/src/lib/auth/hooks/useLogin.js index bef36053..1d5ff43d 100644 --- a/src/lib/auth/hooks/useLogin.js +++ b/src/lib/auth/hooks/useLogin.js @@ -34,7 +34,7 @@ const useLogin = () => { if (login.isAuth) { setAuth(login.user) - router.push('/') + router.push(router.query?.next || '/') return } switch (login.reason) { |
