Hi!
Actually, getUserInfo() is invoked twice in returnFromFb(). Once to get the $fb_profile, then to get the mail field.
if (!$fb_profile = $this->facebookManager->getUserInfo()) {
if (!$email = $this->facebookManager->getUserInfo()->getEmail()) {
The second time could just be:
if (!$email = $fb_profile->getEmail()) {
Sorry, above comment is an aside. The feature request follows:
This variable $fb_profile contains a lot of information that can be usefull to pass to events, so they can be used to populate user entity field. ie. the first/last names, etc.
So, may we pass $fb_profile to authenticateUser() and then pass this and the info returned by getExtraDetails() to events?
Mmm... better yet. $fb_profile could be stored in the {social_auth} table (new column profile_data), so that we could load it at any time to populate user entity fields.
Thank you!
Comments
Comment #2
markus_petrux commentedComment #3
gvsoI attach a patch that fixes the first issue.
With respect to storing the data returned in $profile, I would argue that you can actually just add the fields and endpoints you're interested in in the settings form. Many websites don't really need the information in $profile, so maybe it's not a good idea to store it by default. You can always get the data you want though.
Any thoughts?
Comment #4
markus_petrux commentedDoesn't that mean additional calls to the remote service? (impacts performance and quota limits).
Comment #5
gvsoIf you're gonna request the same basic user information, yes. However, if you want extra info about the user, I guess you're gonna make an extra request to the API since only email and public_profile is by default requested by Social Auth Facebook after authentication.
Comment #6
gvsoI created a new issue where the first problem was solved #2951007: Call getUserInfo() only once
Comment #7
gvsogetUserInfo()stores the user information in the$userproperty. If the method is call inside a module which is using the events, the data will be requested only once.So, I think it's better to leave the task of saving the user information to an external module.