mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-17 01:59:08 +00:00
port full auth flow to cf workers
This commit is contained in:
parent
9eeb946389
commit
aad0987dce
50 changed files with 551 additions and 1167 deletions
|
@ -1,5 +1,9 @@
|
|||
import { NextPageContext } from 'next';
|
||||
import * as React from 'react';
|
||||
import nookies from 'nookies';
|
||||
import { AppShell } from 'roleypoly/design-system/organisms/app-shell';
|
||||
import { Hero } from 'roleypoly/design-system/atoms/hero';
|
||||
import { AccentTitle } from 'roleypoly/design-system/atoms/typography';
|
||||
|
||||
type Props = {
|
||||
sessionID: string;
|
||||
|
@ -9,19 +13,33 @@ const NewSession = (props: Props) => {
|
|||
const { sessionID } = props;
|
||||
React.useEffect(() => {
|
||||
sessionStorage.setItem('session_key', sessionID);
|
||||
|
||||
location.href = '/';
|
||||
}, [sessionID]);
|
||||
|
||||
return <div>Logging you in...</div>;
|
||||
return (
|
||||
<AppShell>
|
||||
<Hero>
|
||||
<AccentTitle>Logging you in...</AccentTitle>
|
||||
</Hero>
|
||||
</AppShell>
|
||||
);
|
||||
};
|
||||
|
||||
NewSession.getInitialProps = (context: NextPageContext): Props => {
|
||||
const sessionID = context.query.session_id;
|
||||
export const getServerSideProps = (context: NextPageContext): { props: Props } => {
|
||||
const sessionID = context.query.session_id as string;
|
||||
if (!sessionID) {
|
||||
throw new Error("I shouldn't be here today.");
|
||||
}
|
||||
|
||||
return { sessionID: sessionID as string };
|
||||
nookies.set(context, 'rp_session_key', sessionID, {
|
||||
httpOnly: true,
|
||||
maxAge: 60 * 60 * 6,
|
||||
path: '/',
|
||||
sameSite: 'strict',
|
||||
});
|
||||
|
||||
return { props: { sessionID } };
|
||||
};
|
||||
|
||||
export default NewSession;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue