Skip to content

Commit

Permalink
Merge pull request #13 from zgid123/fix/nestjs-example-profile-parser
Browse files Browse the repository at this point in the history
fix profile parser logic for nestjs example
  • Loading branch information
zgid123 authored Mar 9, 2023
2 parents c670228 + 9d7d282 commit d68c7a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
15 changes: 7 additions & 8 deletions examples/nestjs/src/strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,20 @@ export class GoogleWithPhoneNumberStrategy extends PassportStrategy(
super({
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_SECRET,
profileURL: 'https://people.googleapis.com/v1/people/me',
profileURL:
'https://people.googleapis.com/v1/people/me?personFields=phoneNumbers,emailAddresses,photos',
scope: [
'email',
'profile',
'https://www.googleapis.com/auth/user.phonenumbers.read',
],
profileParser: (user: IGoogleUserProps): IProfileProps => {
const { names, photos, phoneNumbers, emailAddresses, ...rest } = user;
const { names, photos, phoneNumbers, emailAddresses } = user;
const [name] = names || [];
const [phoneNumber] = phoneNumbers || [];
const [email] = emailAddresses || [];
const { metadata, displayName, familyName, givenName } = name || {};

console.log(emailAddresses);
console.log(rest);
const { displayName, familyName, givenName } = name || {};
const { metadata } = phoneNumber;

return {
provider: 'google',
Expand All @@ -66,8 +65,8 @@ export class GoogleWithPhoneNumberStrategy extends PassportStrategy(
: {},
emails: [
{
value: email.value,
verified: email.metadata.verified,
value: email?.value,
verified: email?.metadata?.verified,
},
],
phoneNumbers: [phoneNumber.value],
Expand Down
7 changes: 6 additions & 1 deletion examples/nestjs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "src",
"declaration": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
Expand All @@ -15,6 +16,7 @@
"noFallthroughCasesInSwitch": false,
"noImplicitAny": false,
"noUncheckedIndexedAccess": true,
"outDir": "dist",
"removeComments": true,
"resolveJsonModule": true,
"skipLibCheck": true,
Expand All @@ -23,5 +25,8 @@
"strictBindCallApply": false,
"strictNullChecks": false,
"target": "esnext"
}
},
"include": [
"./src"
]
}

0 comments on commit d68c7a6

Please sign in to comment.