Skip to content

Commit

Permalink
Merge branch 'main' into fix/csr
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Aug 28, 2024
2 parents a3b602a + 7269c61 commit cf9031f
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions src/runtime/server/lib/oauth/x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function oauthXEventHandler({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const params: any = {
grant_type: 'authorization_code',
code_verifier: config.authorizationParams.code_challenge,
code_verifier: config.authorizationParams?.code_challenge,
redirect_uri: parsePath(redirectURL).pathname,
code,
}
Expand Down Expand Up @@ -144,34 +144,6 @@ export function oauthXEventHandler({
return error
})

if (config.emailRequired) {
// Fetch email if required
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const emailData: any = await $fetch('https://api.twitter.com/1.1/account/verify_credentials.json', {
headers: {
Authorization: `Bearer ${accessToken}`,
},
query: {
include_email: 'true',
skip_status: 'true',
},
}).catch((error) => {
return error
})

if (emailData && emailData.email) {
user.email = emailData.email
}
else {
const error = createError({
statusCode: 401,
message: 'Twitter login failed: no user email found',
})
if (!onError) throw error
return onError(event, error)
}
}

return onSuccess(event, {
tokens,
user: user?.data,
Expand Down

0 comments on commit cf9031f

Please sign in to comment.