Browse Source

Update auth-test.tsx

main
Steve Ruiz 4 years ago
parent
commit
22eaf217da
1 changed files with 12 additions and 20 deletions
  1. 12
    20
      pages/auth-test.tsx

+ 12
- 20
pages/auth-test.tsx View File

@@ -49,34 +49,26 @@ export default function Home({
49 49
 }
50 50
 
51 51
 export async function getServerSideProps(context: GetServerSidePropsContext) {
52
-  let isSponsor = false
53
-
54 52
   const session = await getSession(context)
55 53
 
56
-  if (session?.user) {
57
-    const id = session.user.image.match(/u\/(.*)\?/)?.[1]
58
-
59
-    const sponsors = await fetch(
60
-      'https://sponsors.trnck.dev/sponsors/steveruizok'
61
-    ).then((d) => d.json().then((d) => d.sponsors))
62
-
63
-    const sponsor = sponsors.find(
64
-      (sponsor: { avatar: string }) => sponsor.avatar === session.user.image
65
-    )
54
+  const sponsors = await fetch(
55
+    'https://sponsors.trnck.dev/sponsors/steveruizok'
56
+  ).then((d) => d.json().then((d) => d.sponsors))
66 57
 
67
-    console.log(
68
-      session?.user?.image,
69
-      sponsors.map((sponsor) => sponsor.avatar),
70
-      sponsor
71
-    )
58
+  const sponsor = sponsors.find(
59
+    (sponsor: { avatar: string }) => sponsor.avatar === session?.user?.image
60
+  )
72 61
 
73
-    isSponsor = sponsor !== undefined
74
-  }
62
+  console.log(
63
+    session?.user,
64
+    session?.user?.image,
65
+    sponsors.map((sponsor: any) => sponsor.avatar)
66
+  )
75 67
 
76 68
   return {
77 69
     props: {
78 70
       isOwner: session?.user?.email === 'steveruizok@gmail.com',
79
-      isSponsor,
71
+      isSponsor: sponsor !== undefined,
80 72
       ssrSession: session,
81 73
     },
82 74
   }

Loading…
Cancel
Save