-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #451 from developmentseed/fix/not-signed-in
Provides a page for when user is not signed in
- Loading branch information
Showing
5 changed files
with
54 additions
and
40 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
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 was deleted.
Oops, something went wrong.
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,47 @@ | ||
import { signIn, getProviders } from 'next-auth/react' | ||
import { getServerSession } from 'next-auth/next' | ||
import { Box, Container, Heading, Text, Button } from '@chakra-ui/react' | ||
import InpageHeader from '../components/inpage-header' | ||
import { authOptions } from './api/auth/[...nextauth]' | ||
|
||
export default function SignIn() { | ||
return ( | ||
<> | ||
<Box as='main' mb={8}> | ||
<InpageHeader> | ||
<Heading color='white' mb={2}> | ||
You are not signed in. | ||
</Heading> | ||
</InpageHeader> | ||
<Container maxW='container.xl' as='section'> | ||
<Box layerStyle={'shadowed'}> | ||
<Text fontSize='2xl'> | ||
Sorry, you need to be signed in to view this page. | ||
</Text> | ||
<Button my={4} onClick={() => signIn('osm-teams')}> | ||
Sign in → | ||
</Button> | ||
<Text>Still having problems? Contact a system administrator.</Text> | ||
</Box> | ||
</Container> | ||
</Box> | ||
</> | ||
) | ||
} | ||
|
||
export async function getServerSideProps(context) { | ||
const session = await getServerSession(context.req, context.res, authOptions) | ||
|
||
// If the user is already logged in, redirect. | ||
// Note: Make sure not to redirect to the same page | ||
// To avoid an infinite loop! | ||
if (session) { | ||
return { redirect: { destination: '/' } } | ||
} | ||
|
||
const providers = await getProviders() | ||
|
||
return { | ||
props: { providers: providers ?? [] }, | ||
} | ||
} |