update auth
This commit is contained in:
parent
00fe07c6c3
commit
fdf82d3a91
2 changed files with 16 additions and 7 deletions
|
@ -7,6 +7,15 @@ const options = {
|
|||
Providers.GitHub({
|
||||
clientId: process.env.GITHUB_ID,
|
||||
clientSecret: process.env.GITHUB_SECRET,
|
||||
profile(profile) {
|
||||
return {
|
||||
id: profile.id,
|
||||
login: profile.login,
|
||||
name: profile.name || profile.login,
|
||||
email: profile.email,
|
||||
image: profile.avatar_url,
|
||||
} as any
|
||||
},
|
||||
}),
|
||||
],
|
||||
callbacks: {
|
||||
|
|
|
@ -49,22 +49,22 @@ export default function Home({
|
|||
}
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
const session = await getSession(context)
|
||||
const session: any = await getSession(context)
|
||||
|
||||
const id = session?.user?.image.match(/u\/(.*)\?/)?.[1]
|
||||
const handle = session?.user?.login
|
||||
|
||||
const sponsors = await fetch(
|
||||
'https://sponsors.trnck.dev/sponsors/steveruizok'
|
||||
).then((d) => d.json().then((d) => d.sponsors))
|
||||
|
||||
const sponsor = sponsors.find((sponsor: { avatar: string }) =>
|
||||
sponsor.avatar.includes(id)
|
||||
const sponsor = sponsors.some(
|
||||
(sponsor: { handle: string }) => sponsor.handle === handle
|
||||
)
|
||||
|
||||
console.log(
|
||||
session?.user,
|
||||
id,
|
||||
sponsors.map((sponsor: any) => sponsor.avatar)
|
||||
session,
|
||||
handle,
|
||||
sponsors.map((sponsor: any) => sponsor.handle)
|
||||
)
|
||||
|
||||
return {
|
||||
|
|
Loading…
Reference in a new issue