Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/pages/auth/sign-in.tsx
6037 views
1
/*
2
* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { Layout } from "antd";
7
import { useRouter } from "next/router";
8
9
import SignIn from "components/auth/sign-in";
10
import Footer from "components/landing/footer";
11
import Head from "components/landing/head";
12
import Header from "components/landing/header";
13
import basePath from "lib/base-path";
14
import { Customize } from "lib/customize";
15
import withCustomize from "lib/with-customize";
16
17
export default function Home({ customize }) {
18
const { siteName = "CoCalc" } = customize ?? {};
19
const router = useRouter();
20
return (
21
<Customize value={customize}>
22
<Head title={`Sign in to ${siteName}`} />
23
<Layout>
24
<Header page="sign-in" />
25
<Layout.Content style={{ backgroundColor: "white" }}>
26
<SignIn onSuccess={() => router.push("/app?sign-in")} />
27
<Footer />
28
</Layout.Content>
29
</Layout>
30
</Customize>
31
);
32
}
33
34
export async function getServerSideProps(context) {
35
const customize = await withCustomize({ context });
36
if (customize.props.customize.account != null) {
37
// user is already signed in -- redirect them to top level page.
38
const { res } = context;
39
res.writeHead(302, { location: basePath });
40
res.end();
41
return { props: { customize: {} } };
42
}
43
return customize;
44
}
45
46