Skip to content

Commit 7269c61

Browse files
committed
chore: fix X
1 parent a1b3fbb commit 7269c61

File tree

1 file changed

+1
-29
lines changed
  • src/runtime/server/lib/oauth

1 file changed

+1
-29
lines changed

src/runtime/server/lib/oauth/x.ts

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export function oauthXEventHandler({
105105
// eslint-disable-next-line @typescript-eslint/no-explicit-any
106106
const params: any = {
107107
grant_type: 'authorization_code',
108-
code_verifier: config.authorizationParams.code_challenge,
108+
code_verifier: config.authorizationParams?.code_challenge,
109109
redirect_uri: parsePath(redirectURL).pathname,
110110
code,
111111
}
@@ -144,34 +144,6 @@ export function oauthXEventHandler({
144144
return error
145145
})
146146

147-
if (config.emailRequired) {
148-
// Fetch email if required
149-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
150-
const emailData: any = await $fetch('https://api.twitter.com/1.1/account/verify_credentials.json', {
151-
headers: {
152-
Authorization: `Bearer ${accessToken}`,
153-
},
154-
query: {
155-
include_email: 'true',
156-
skip_status: 'true',
157-
},
158-
}).catch((error) => {
159-
return error
160-
})
161-
162-
if (emailData && emailData.email) {
163-
user.email = emailData.email
164-
}
165-
else {
166-
const error = createError({
167-
statusCode: 401,
168-
message: 'Twitter login failed: no user email found',
169-
})
170-
if (!onError) throw error
171-
return onError(event, error)
172-
}
173-
}
174-
175147
return onSuccess(event, {
176148
tokens,
177149
user: user?.data,

0 commit comments

Comments
 (0)