Skip to content

Commit

Permalink
Bug fixes and improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
algarfer committed Mar 27, 2024
1 parent b796a91 commit c15babb
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
4 changes: 4 additions & 0 deletions gatewayservice/middleware/DataValidatorMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ module.exports = function (req, res, next) {

// Signup password validation
if(req.originalUrl === "/adduser") {
if (username.trim().length === 0) {
res.status(400).json({ error: "Username should not be empty" });
return;
}
if (password.length < 8) {
res.status(400).json({ error: "Password must be at least 8 characters long" });
return;
Expand Down
2 changes: 0 additions & 2 deletions webapp/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import About from "./views/About";
import Ranking from "./views/Ranking";
import Menu from "./views/Menu";
import Game from "./views/Game";
import Logout from "./views/components/Logout"
import Account from "./views/Account";
import Error from "./views/Error";
import { ThemeProvider, createTheme } from "@mui/material/styles";
Expand Down Expand Up @@ -135,7 +134,6 @@ export default function App() {
<Route path="/home" element={<Home />} />
<Route path="/signup" element={<Signup />} />
<Route path="/login" element={<Login/>} />
<Route path="/logout" element={<Logout />} />
<Route path="/about" element={<About />} />
<Route path="/ranking" element={<Ranking />} />
<Route path="/menu" element={<Menu />} />
Expand Down
8 changes: 7 additions & 1 deletion webapp/src/views/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ const buttonConfig = {
height: "5rem",
}

const buttonGroup = {display: "flex", justifyContent: "space-evenly", margin: "1rem 0"}
const buttonGroup = {
display: "flex",
flexFlow: "row wrap",
justifyContent: "space-evenly",
margin: "1rem 0",
gap: "1rem"
}

const MyButton = ({text, link}) => {
return (
Expand Down
11 changes: 0 additions & 11 deletions webapp/src/views/components/Logout.jsx

This file was deleted.

24 changes: 17 additions & 7 deletions webapp/src/views/components/Nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const settings = [

export default function Nav() {

const { isAuthenticated, getUser } = useContext(AuthContext)
const { isAuthenticated, getUser, logout } = useContext(AuthContext)
const [anchorElNav, setAnchorElNav] = useState(null);
const [anchorElUser, setAnchorElUser] = useState(null);
const [width, setWidth] = useState(window.innerWidth);
Expand Down Expand Up @@ -95,6 +95,21 @@ export default function Nav() {
);
};

const generateMenuItems = () => {
return settings.map((setting) => {
if (isAuthenticated() !== setting.logged) return null
return (
<MenuItem
key={setting.displayed}
onClick={setting.link === '/logout' ? () => {handleCloseUserMenu(); logout()} : handleCloseUserMenu}
component={Link}
to={setting.link === '/logout' ? "/" : setting.link}>
<Typography textAlign="center">{setting.displayed}</Typography>
</MenuItem>
)
})
}

return (
<AppBar position="sticky">
<Container maxWidth="xl">
Expand All @@ -119,12 +134,7 @@ export default function Nav() {
open={Boolean(anchorElUser)}
onClose={handleCloseUserMenu}
>
{settings.map((setting) => {
if (isAuthenticated() !== setting.logged) return null
return (<MenuItem key={setting.displayed} onClick={handleCloseUserMenu} component={Link} to={setting.link}>
<Typography textAlign="center">{setting.displayed}</Typography>
</MenuItem>)
})}
{generateMenuItems()}
</Menu>
</Box>
</Toolbar>
Expand Down

0 comments on commit c15babb

Please sign in to comment.