diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 000000000..b58b603fe --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 000000000..03d9549ea --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..35eb1ddfb --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/system/apps/blog/core/auth/use-auth.ts b/system/apps/blog/core/auth/use-auth.ts index eaf5d0517..4c3ed5a7a 100644 --- a/system/apps/blog/core/auth/use-auth.ts +++ b/system/apps/blog/core/auth/use-auth.ts @@ -1,22 +1,29 @@ -import { unauthorize, useAuthStore } from '../../store/auth'; -import { interceptUnauthorized } from '@system/blog-api'; -import { useEffect } from 'react'; +import {unauthorize, useAuthStore} from '../../store/auth'; +import {interceptUnauthorized} from '@system/blog-api'; +import {useEffect} from 'react'; +import {useRouter} from 'next/navigation'; +import {useLang} from '../../dk'; const useAuth = () => { const authStore = useAuthStore(); + const router = useRouter(); + const lang = useLang(); useEffect(() => { - const { listen, clean } = interceptUnauthorized(unauthorize); - + const {listen, clean} = interceptUnauthorized(() => { + unauthorize(); + router.push(`/${lang}/articles`); + }); listen(); - authStore.check(); + router.push(`/${lang}/articles`); + return () => { clean(); }; // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + }, [authStore.key]); }; -export { useAuth }; +export {useAuth};