Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dont display ui when logged out #401

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ function App() {
dispatch(fetchUserInfo());
// Load information about current opencast version on mount
dispatch(fetchOcVersion());

// Add event listener for back button to check if we are still logged in
window.addEventListener("popstate", function(event) {
dispatch(fetchUserInfo());
});

// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand Down
5 changes: 5 additions & 0 deletions src/slices/userInfoSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ export const fetchUserInfo = createAsyncThunk('UserInfo/fetchUserInfo', async (_
dispatch(addNotification({type: "error", key: "USER_NOT_SAVED"}));
});

// Redirect to login if not in ROLE_ADMIN_UI
if (!(res.roles.includes('ROLE_ADMIN') || res.roles.includes('ROLE_ADMIN_UI'))) {
window.location.href = "/login.html";
}

return res;
});

Expand Down
Loading