-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
480 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import NextAuth from 'next-auth'; | ||
import Providers from 'next-auth/providers'; | ||
|
||
const options = { | ||
// Configure one or more authentication providers | ||
providers: [ | ||
Providers.Okta({ | ||
clientId: process.env.OKTA_CLIENTID, | ||
clientSecret: process.env.OKTA_CLIENTSECRET, | ||
domain: process.env.OKTA_DOMAIN, | ||
}), | ||
// ...add more providers here | ||
], | ||
}; | ||
|
||
const handler = (req, res) => NextAuth(req, res, options); | ||
|
||
export { handler as GET, handler as POST }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import styled from '@emotion/styled'; | ||
import { signIn, useSession } from 'next-auth/client'; | ||
|
||
import Button from '@leafygreen-ui/button'; | ||
import Icon from '@leafygreen-ui/icon'; | ||
import { | ||
FocusableMenuItem, | ||
Menu as LGMenu, | ||
MenuItem, | ||
} from '@leafygreen-ui/menu'; | ||
import { palette } from '@leafygreen-ui/palette'; | ||
import { spacing } from '@leafygreen-ui/tokens'; | ||
import { Body, Description } from '@leafygreen-ui/typography'; | ||
|
||
const Container = styled('div')` | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: flex-end; | ||
padding-top: ${spacing[4]}px; | ||
z-index: 1; | ||
// todo: remove | ||
gap: 8px; | ||
`; | ||
|
||
const Menu = styled(LGMenu)` | ||
padding: 0; | ||
width: unset; | ||
background-color: ${palette.gray.dark3}; | ||
`; | ||
|
||
const UserMenuTrigger = styled(Button)``; | ||
|
||
const UserInfoContainer = styled('div')` | ||
display: flex; | ||
align-items: center; | ||
gap: ${spacing[4]}px; | ||
padding: ${spacing[4]}px; | ||
`; | ||
|
||
const Avatar = styled('div')` | ||
border-radius: 50%; | ||
min-width: 36px; | ||
min-height: 36px; | ||
background-color: ${palette.gray.base}; | ||
color: white; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
text-transform: capitalize; | ||
`; | ||
|
||
const LogOutMenuItem = styled(MenuItem)` | ||
padding: 20px; | ||
`; | ||
|
||
const DesktopSignIn = () => { | ||
const [session, loading] = useSession(); | ||
|
||
// todo: replace with real values | ||
const user = { | ||
firstName: 'Sean', | ||
lastName: 'Park', | ||
email: 's.park@mongodb.com', | ||
}; | ||
|
||
return ( | ||
<Container> | ||
<Button | ||
variant="primaryOutline" | ||
leftGlyph={<Icon glyph="LogIn" />} | ||
onClick={signIn} | ||
> | ||
Log in | ||
</Button> | ||
<Menu | ||
trigger={ | ||
<UserMenuTrigger rightGlyph={<Icon glyph="CaretDown" />}> | ||
{user.firstName} | ||
</UserMenuTrigger> | ||
} | ||
> | ||
<FocusableMenuItem> | ||
<UserInfoContainer> | ||
<Avatar>{user.firstName[0]}</Avatar> | ||
<div> | ||
<Body darkMode> | ||
{user.firstName} {user.lastName} | ||
</Body> | ||
<Description darkMode>{user.email}</Description> | ||
</div> | ||
</UserInfoContainer> | ||
</FocusableMenuItem> | ||
<LogOutMenuItem glyph={<Icon glyph="LogOut" />}>Log out</LogOutMenuItem> | ||
</Menu> | ||
{/* TODO: replace the above with this logic */} | ||
{/* {session | ||
? <Menu trigger={<UserMenuTrigger rightGlyph={<Icon glyph="CaretDown" />}>{userName} </UserMenuTrigger>} /> | ||
: <Button variant="primaryOutline" leftGlyph={<Icon glyph="LogIn" />} onClick={signIn}>Log in</Button> | ||
} */} | ||
</Container> | ||
); | ||
}; | ||
|
||
export default DesktopSignIn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.