Skip to content

Commit 9221042

Browse files
agustifAgusti Fernandez Pardokodiakhq[bot]zomars
authoredAug 9, 2022
feat: signin test email magic signup in app (#3749)
* feat: signin test email magic signup in app * fix: no signIn page in nextauth * fix: remove commented signIN * Update apps/web/pages/auth/signin.tsx remove import useRouter Co-authored-by: Omar López <zomars@me.com> Co-authored-by: Agusti Fernandez Pardo <git@agusti.me> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Omar López <zomars@me.com>
1 parent b936b7c commit 9221042

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
 

‎apps/web/pages/auth/signin.tsx

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { GetServerSidePropsContext } from "next";
2+
import { getProviders, signIn, getSession, getCsrfToken } from "next-auth/react";
3+
4+
import { Button } from "@calcom/ui/v2";
5+
6+
type Provider = {
7+
name: string;
8+
id: string;
9+
};
10+
11+
function signin({ providers }: { providers: Provider[] }) {
12+
return (
13+
<div className="center mt-10 justify-between space-y-5 text-center align-baseline">
14+
{Object.values(providers).map((provider) => {
15+
return (
16+
<div key={provider.name}>
17+
<Button onClick={() => signIn(provider.id)}>Sign in with {provider.name}</Button>
18+
</div>
19+
);
20+
})}
21+
</div>
22+
);
23+
}
24+
25+
export default signin;
26+
27+
export async function getServerSideProps(context: GetServerSidePropsContext) {
28+
const session = await getSession(context);
29+
const csrfToken = await getCsrfToken(context);
30+
const providers = await getProviders();
31+
if (session) {
32+
return {
33+
redirect: { destination: "/" },
34+
};
35+
}
36+
return {
37+
props: {
38+
csrfToken,
39+
providers,
40+
},
41+
};
42+
}

0 commit comments

Comments
 (0)