diff --git a/front/src/applications/stdcm/components/StdcmHeader.tsx b/front/src/applications/stdcm/components/StdcmHeader.tsx index 4e82c10b3f6..3497bbf954a 100644 --- a/front/src/applications/stdcm/components/StdcmHeader.tsx +++ b/front/src/applications/stdcm/components/StdcmHeader.tsx @@ -22,18 +22,18 @@ const StdcmHeader = ({ isDebugMode, onDebugModeToggle }: StdcmHeaderProps) => { {t('notificationTitle')} - -
- -
+ {isSuperUser && ( +
+ +
+ )} ); }; diff --git a/front/src/main/app.tsx b/front/src/main/app.tsx index b682965cb8d..48eaaa797cb 100644 --- a/front/src/main/app.tsx +++ b/front/src/main/app.tsx @@ -122,12 +122,12 @@ export default function App() { // Blindly dispatch current front version for storage dispatch(updateLastInterfaceVersion(import.meta.env.OSRD_GIT_DESCRIBE)); }, []); - const { isUserLogged, isUserRolesFetched } = useAuth(); + const { isLoading } = useAuth(); return ( }> - {isUserLogged && isUserRolesFetched && } - {(!isUserLogged || !isUserRolesFetched) && } + {!isLoading && } + {isLoading && } ); } diff --git a/front/src/utils/hooks/OsrdAuth.ts b/front/src/utils/hooks/OsrdAuth.ts index f54bc7e3dc0..80f8dadce09 100644 --- a/front/src/utils/hooks/OsrdAuth.ts +++ b/front/src/utils/hooks/OsrdAuth.ts @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react'; +import { useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; @@ -11,12 +11,10 @@ type AuthHookData = { username?: string; isUserLogged: boolean; isLoading: boolean; - isUserRolesFetched: boolean; logout: () => void; }; function useAuth(): AuthHookData { - const [isUserRolesFetched, setIsUserRolesFetched] = useState(false); const isUserLogged = useSelector(getIsUserLogged); const username = useSelector(getUsername); const dispatch = useDispatch(); @@ -39,15 +37,13 @@ function useAuth(): AuthHookData { useEffect(() => { if (data) { dispatch(setUserRoles(data?.builtin)); - setIsUserRolesFetched(true); } }, [isUserLogged, data]); return { username, isUserLogged, - isLoading: isAuthenticateLoading, - isUserRolesFetched, + isLoading: isAuthenticateLoading || !data, logout, }; }