strongloop / loopback-example-passport

LoopBack example for facebook login
Other
185 stars 134 forks source link

Proper profile model to store fields returned from Facebook, Google, etc.... #74

Closed artmunro closed 7 years ago

artmunro commented 8 years ago

There should be a proper profile model with relationship to user. If you provide profileFields suggested by passport within the providers.json, then these fields should be stored in a profile model. Developers can then have the chance to extend this model to suit their needs.

If you currently use a relational DB such as Postgres there will be an error due to profile field default length not large enough for the default field size as current implementation has all profile fields stored in single field.

I have implemented a hook after user create but I think it would be cleaner to have as part of the implementation of module.

ddbaron commented 8 years ago

@artmunro I agree with you. As a workaround, you can change the datatype of the postgres field to either be longer (from 1024 to 2048 or more) or change it to 'text'. I have done this to deal with fields longer than the default 1024. NOTE: I did this directly to postgres, thus automigrate/autoupdate would overwrite those changes if you use them in the future.

tention commented 7 years ago

@artmunro Can I know how you save the profile fields through a hook? I tried to get the value through a hook but i'm not able to retrieve profile fields properly.

The following commands would get me "undefined" for the profile object instead of the proper value. console.log('profileId: ', ctx.instance.profileId); console.log('displayName: ', ctx.instance.profile.displayName); console.log('familyName: ', ctx.instance.profile.familyName); console.log('gender: ', ctx.instance.credentials);

The same codes however works for profileId and the credentials objects that returned together. profileId: 2 displayName: undefined familyName: undefined credentials: { accessToken: 'EAAXnXmZAgQvgBANKlWtHXNZCZAaveVI65NwOKEu5ZA8BT04eVvcJGZA10HNYH4C8EnNnMFBBiciP0M4S6fDBst6jNIXgQteXO495SYagAOXFpjULQ4GQZBDU9tZA2c0qRr9y0t4q2QcMcgn6XrGHfKn1KigsGeyV9QZD' }

stale[bot] commented 7 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.