summaryrefslogtreecommitdiff
path: root/src/lib/auth
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/auth')
-rw-r--r--src/lib/auth/components/IsAuth.jsx4
-rw-r--r--src/lib/auth/hooks/useLogin.js2
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) {