New login screen (#1331)

* wip

* feat: first draft of auth.config

* chore: auth methodS

* chore: styling

* styling, styling, styling

* feat: Auth notices

* chore: Remove server-rendered pages, move shared/components -> components

* lint

* cleanup

* cleanup

* fix: Remove unused component

* fix: Ensure env variables in prod too

* style tweaks

* fix: Entering SSO email into login form fails
fix: Tweak language around guest signin
This commit is contained in:
Tom Moor
2020-07-09 22:33:07 -07:00
committed by GitHub
parent 75561079eb
commit 5cb04d7ac1
128 changed files with 769 additions and 2264 deletions

View File

@@ -1,47 +0,0 @@
// @flow
import * as React from "react";
import ReactDOMServer from "react-dom/server";
import { Helmet } from "react-helmet";
import {
ServerStyleSheet,
StyleSheetManager,
ThemeProvider,
} from "styled-components";
import Layout from "../pages/components/Layout";
import { light } from "../../shared/styles/theme";
export default function renderpage(ctx: Object, children: React.Node) {
let sessions = {};
try {
sessions = JSON.parse(
decodeURIComponent(ctx.cookies.get("sessions") || "") || "{}"
);
} catch (err) {
console.error(`Sessions cookie could not be parsed: ${err}`);
}
const sheet = new ServerStyleSheet();
const loggedIn = !!(
ctx.cookies.get("accessToken") || Object.keys(sessions).length
);
const html = ReactDOMServer.renderToString(
<StyleSheetManager sheet={sheet.instance}>
<ThemeProvider theme={light}>
<Layout sessions={sessions} loggedIn={loggedIn}>
{children}
</Layout>
</ThemeProvider>
</StyleSheetManager>
);
// helmet returns an object of meta tags with toString methods, urgh.
const helmet = Helmet.renderStatic();
let head = "";
// $FlowFixMe
Object.keys(helmet).forEach(key => (head += helmet[key].toString()));
ctx.body = `<!DOCTYPE html>\n${html}`
.replace("{{CSS}}", sheet.getStyleTags())
.replace("{{HEAD}}", head);
}