Skip to content

Commit

Permalink
fix(passport): fallback twitter account profile (#2550)
Browse files Browse the repository at this point in the history
  • Loading branch information
szkl authored Jul 26, 2023
1 parent ac81e8e commit 7a0c000
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions platform/address/src/nodes/twitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,21 @@ export default class TwitterAddress extends OAuthAddress {
const data = await this.getData()
if (!data) throw new InternalServerError({ message: 'no data' })
const profile = data.profile as TwitterOAuthProfile
return {
address: profile.username,
title: profile.name,
icon: profile.picture,
type: OAuthAddressType.Twitter,
if (profile && profile.username) {
return {
address: profile.username,
title: profile.name,
icon: profile.picture,
type: OAuthAddressType.Twitter,
}
} else {
const address = await this.node.class.getAddress()
return {
address: address || 'Twitter',
title: 'Twitter',
disconnected: true,
type: OAuthAddressType.Twitter,
}
}
}

Expand Down

0 comments on commit 7a0c000

Please sign in to comment.