From 4f229ff642f1658b4f0d23f00651c7d44f071c65 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Sun, 24 Apr 2022 13:10:46 +0200 Subject: [PATCH] Previous commit extended --- src/client/src/AdminsOverview.js | 35 ++++++++++++++++++--------- src/client/src/LoginPage.js | 10 ++++---- src/client/src/TournamentCreator.js | 4 ++- src/client/src/TournamentMatches.js | 2 +- src/client/src/components/AsuraBar.js | 6 +++-- 5 files changed, 36 insertions(+), 21 deletions(-) diff --git a/src/client/src/AdminsOverview.js b/src/client/src/AdminsOverview.js index 112e0d0..cae1079 100644 --- a/src/client/src/AdminsOverview.js +++ b/src/client/src/AdminsOverview.js @@ -2,7 +2,7 @@ import * as React from "react"; import { BrowserRouter as Router, Link, Route, Routes, useParams } from "react-router-dom"; import Appbar from "./components/AsuraBar"; import ErrorSnackbar from "./components/ErrorSnackbar"; - +import LoginPage from "./LoginPage"; import {Button, Box, TextField, Stack, InputLabel, Paper, TableContainer, Table, TableBody, TableHead, TableCell, TableRow, Typography} from '@mui/material'; import AddCircleIcon from '@mui/icons-material/AddCircle'; import DeleteIcon from '@mui/icons-material/Delete'; @@ -124,18 +124,29 @@ export default function Users(props) { setUsers(data.data); }) .catch((err) => showError(err)); - } - React.useEffect(() => { - getUsers() - }, []); + } + React.useEffect(() => { + getUsers() + }, []); - return ( - <> + if (!props.user.isLoggedIn) { return ; } + if (!props.user.isManager) { + return (<> -
- - + +
+ You do not have permission to view this page. If you believe this is incorrect, please contact a manager.
- - ); +
+ ); + } + return ( + <> + +
+ + +
+ + ); } \ No newline at end of file diff --git a/src/client/src/LoginPage.js b/src/client/src/LoginPage.js index 4537bb4..b99e863 100644 --- a/src/client/src/LoginPage.js +++ b/src/client/src/LoginPage.js @@ -15,11 +15,11 @@ export default function LoginPage(props) { return ( <> - - - You must be logged in to access administrator features. - - + + + + You must be logged in to access administrator features. + Sign in with google diff --git a/src/client/src/TournamentCreator.js b/src/client/src/TournamentCreator.js index ab8d6fb..ca3fe6a 100644 --- a/src/client/src/TournamentCreator.js +++ b/src/client/src/TournamentCreator.js @@ -2,7 +2,7 @@ import * as React from "react"; import { BrowserRouter as Router, Link, Route, Routes } from "react-router-dom"; import Appbar from "./components/AsuraBar"; import ErrorSnackbar from "./components/ErrorSnackbar"; - +import LoginPage from "./LoginPage"; import { Button, TextField, Stack, InputLabel, Select, Container, Slider, Paper, Box, Grid, Typography } from '@mui/material'; import DateTimePicker from '@mui/lab/DateTimePicker'; import AdapterDateFns from '@mui/lab/AdapterDateFns'; @@ -168,6 +168,8 @@ export default function TournamentCreator(props) { setOpenError(true); } + if (!props.user.isLoggedIn) { return ; } + return ( <> diff --git a/src/client/src/TournamentMatches.js b/src/client/src/TournamentMatches.js index 8311309..6f95ae3 100644 --- a/src/client/src/TournamentMatches.js +++ b/src/client/src/TournamentMatches.js @@ -9,7 +9,7 @@ function MatchHistory() { ); } -export default function TournamentMatches() { +export default function TournamentMatches(props) { return ( <> diff --git a/src/client/src/components/AsuraBar.js b/src/client/src/components/AsuraBar.js index a9bd7ee..f27ce89 100644 --- a/src/client/src/components/AsuraBar.js +++ b/src/client/src/components/AsuraBar.js @@ -9,7 +9,7 @@ import LogoutIcon from '@mui/icons-material/Logout'; import LoginIcon from '@mui/icons-material/Login'; import logo from "./../Asura2222.png"; -function LoggedInMenu() { +function LoggedInMenu(props) { const [anchorEl, setAnchorEl] = React.useState(null); const open = Boolean(anchorEl); const handleClick = (event) => { @@ -32,7 +32,9 @@ function LoggedInMenu() { + { props.user.isManager && + } ); @@ -83,7 +85,7 @@ export default function Appbar(props) { { props.pageTitle !== "Login" ? - { props.user.isLogggedIn ? : } + { props.user.isLoggedIn ? : } :