mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
Merge branch 'fix/redirect-error' into 'development'
[HOTFIX/FE] Fixing redirect issues See merge request mbugroup/lti-web-client!88
This commit is contained in:
+14
-1
@@ -2,17 +2,30 @@
|
|||||||
|
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { useAuth } from '@/services/hooks/useAuth';
|
||||||
|
import { redirectToSSO } from '@/lib/auth-helper';
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
|
const { user, isLoadingUser } = useAuth();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
router.replace('/dashboard');
|
router.replace('/dashboard');
|
||||||
}, [router]);
|
}, [user, isLoadingUser]);
|
||||||
|
|
||||||
|
if (isLoadingUser) {
|
||||||
return (
|
return (
|
||||||
<main className='w-full h-full min-h-screen flex flex-row justify-center items-center'>
|
<main className='w-full h-full min-h-screen flex flex-row justify-center items-center'>
|
||||||
<span className='loading loading-spinner loading-lg'></span>
|
<span className='loading loading-spinner loading-lg'></span>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isLoadingUser && !user) {
|
||||||
|
redirectToSSO();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ const RequireAuth = ({ children }: RequireAuthProps) => {
|
|||||||
}
|
}
|
||||||
}, [userErrorResponse, setUser]);
|
}, [userErrorResponse, setUser]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setIsLoadingUser(isLoadingUserResponse);
|
||||||
|
}, [isLoadingUserResponse]);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(isLoadingUserResponse && !userResponse && !userErrorResponse) ||
|
(isLoadingUserResponse && !userResponse && !userErrorResponse) ||
|
||||||
(!userResponse && !userErrorResponse)
|
(!userResponse && !userErrorResponse)
|
||||||
|
|||||||
Reference in New Issue
Block a user