File tree 1 file changed +42
-0
lines changed
1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments