Skip to content

Commit

Permalink
Merge pull request #387 from ArendPeter/hide-email
Browse files Browse the repository at this point in the history
Rework login / logout button
  • Loading branch information
ArendPeter authored Nov 22, 2023
2 parents 3262a9d + 525057b commit e5516bb
Showing 1 changed file with 37 additions and 73 deletions.
110 changes: 37 additions & 73 deletions frontend/src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,92 +147,56 @@ const Header = ({ authSession }) => {
<Typography variant={navVariant} sx={{ fontWeight: 'bold' }} color={headerTextColor}>
Sandbox
</Typography>

</Button>
</Box>

{/**** LOG IN/OUT ****/}
<Box variant="h5" sx={{ alignItems: 'center', flexWrap: 'wrap', flexGrow: 0, display: { xs: 'none', md: 'flex' } }}>

{authSession.isLoggedIn() ?
<>
<Typography variant={navVariant} sx={{ fontWeight: 'medium' }} color={headerTextColor}>
<Box sx={{ flexGrow: 0, display: 'flex' }}>
{authSession.isLoggedIn() && <>
<IconButton
size="large"
aria-label="account of current user"
aria-controls="menu-appbar"
aria-haspopup="true"
onClick={handleOpenUserMenu}
color="inherit">
<AccountCircleIcon />
</IconButton>
<Menu
id="menu-appbar"
anchorEl={anchorElUser}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'left',
}}
keepMounted
transformOrigin={{
vertical: 'top',
horizontal: 'left',
}}
open={Boolean(anchorElUser)}
onClose={handleCloseUserMenu}
sx={{ display: 'block'}}
>
<MenuItem>
{authSession.getIdField('email')}
</Typography>
<Button
</MenuItem>
<MenuItem
color='inherit'
onClick={() => authSession.openLogout()}
>
<Typography variant={navVariant} sx={{ fontWeight: 'bold' }} color={headerTextColor}>
Log Out
</Typography>
</Button>
</>
:
<Button
color='inherit'
onClick={() => authSession.openLogin()}
>

Logout
</MenuItem>
</Menu>
</>}
{!authSession.isLoggedIn() &&
<Button color='inherit' onClick={() => authSession.openLogin()} >
<Typography variant={navVariant} sx={{ fontWeight: 'bold' }} color={headerTextColor}>
Log In
Login
</Typography>
</Button>
}
</Box>
<Box sx={{ flexGrow: 0, display: { xs: 'flex', md: 'none' } }}>
<IconButton
size="large"
aria-label="account of current user"
aria-controls="menu-appbar"
aria-haspopup="true"
onClick={handleOpenUserMenu}
color="inherit">
<AccountCircleIcon />
</IconButton>
<Menu
id="menu-appbar"
anchorEl={anchorElUser}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'left',
}}
keepMounted
transformOrigin={{
vertical: 'top',
horizontal: 'left',
}}
open={Boolean(anchorElUser)}
onClose={handleCloseUserMenu}
sx={{
display: { xs: 'block', md: 'none' },
}}
>
{authSession.isLoggedIn() ?
<>
<MenuItem>
{authSession.getIdField('email')}
</MenuItem>
<MenuItem
color='inherit'
onClick={() => authSession.openLogout()}
>
Logout
</MenuItem>
</>
:
<>
<MenuItem
color='inherit'
onClick={() => authSession.openLogin()}
>
Login
</MenuItem>
</>
}

</Menu>
</Box>

</Toolbar>
</AppBar >
Expand Down

0 comments on commit e5516bb

Please sign in to comment.