diff --git a/src/App.tsx b/src/App.tsx index 0f7b653..d556ce1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -10,7 +10,9 @@ import { LoginCallback } from './modules/login/LoginCallback'; // eslint-disable-next-line @typescript-eslint/no-unused-vars function App() { - const { authToken } = useAuth(); + const { authToken, currentUser } = useAuth(); + + const redirectToLogin = !authToken || !currentUser?.app_roles; return ( <> @@ -26,7 +28,7 @@ function App() {
- {!authToken ? ( + {redirectToLogin ? ( } /> } /> diff --git a/src/modules/users/components/UserModal/consts.ts b/src/modules/users/components/UserModal/consts.ts index abda708..a47d6de 100644 --- a/src/modules/users/components/UserModal/consts.ts +++ b/src/modules/users/components/UserModal/consts.ts @@ -12,7 +12,7 @@ export const appAccessList = [ label: 'Wordpress', }, { - name: 'next-cloud', + name: 'nextcloud', image: '/assets/nextcloud.svg', label: 'NextCloud', }, @@ -37,7 +37,7 @@ const initialAppRoles = [ role: UserRole.User, }, { - name: 'next-cloud', + name: 'nextcloud', role: UserRole.User, }, { diff --git a/src/services/auth/redux/selectors.ts b/src/services/auth/redux/selectors.ts index c7ee882..0feaae5 100644 --- a/src/services/auth/redux/selectors.ts +++ b/src/services/auth/redux/selectors.ts @@ -12,6 +12,9 @@ export const getCurrentUser = (state: State) => state.auth.userInfo; export const getIsAdmin = (state: State) => { // check since old users wont have this if (state.auth.userInfo) { + if (!state.auth.userInfo.app_roles) { + return false; + } const isAdmin = state.auth.userInfo.app_roles.find( (role) => role.name === 'dashboard' && role.role === UserRole.Admin, );