update auth

This commit is contained in:
Steve Ruiz 2021-06-19 19:50:24 +01:00
parent 00fe07c6c3
commit fdf82d3a91
2 changed files with 16 additions and 7 deletions

View file

@ -7,6 +7,15 @@ const options = {
Providers.GitHub({ Providers.GitHub({
clientId: process.env.GITHUB_ID, clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET, 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: { callbacks: {

View file

@ -49,22 +49,22 @@ export default function Home({
} }
export async function getServerSideProps(context: GetServerSidePropsContext) { 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( const sponsors = await fetch(
'https://sponsors.trnck.dev/sponsors/steveruizok' 'https://sponsors.trnck.dev/sponsors/steveruizok'
).then((d) => d.json().then((d) => d.sponsors)) ).then((d) => d.json().then((d) => d.sponsors))
const sponsor = sponsors.find((sponsor: { avatar: string }) => const sponsor = sponsors.some(
sponsor.avatar.includes(id) (sponsor: { handle: string }) => sponsor.handle === handle
) )
console.log( console.log(
session?.user, session,
id, handle,
sponsors.map((sponsor: any) => sponsor.avatar) sponsors.map((sponsor: any) => sponsor.handle)
) )
return { return {