dcblogdev / laravel-microsoft-graph

Laravel package for Microsoft Graph API (Microsoft365)
https://dcblog.dev/docs/laravel-microsoft-graph
Other
124 stars 53 forks source link

Mail is null #20

Closed rsf123 closed 2 years ago

rsf123 commented 3 years ago

In some cases, the mail value in the token is returning null. I modified the listener in my app to look at userPrincipalName and update the token in the database appropraitely. However, it looks like the MsGraph code is overwriting this:

           //find record and add email - not required but useful none the less
            $t = MsGraphToken::findOrFail($result->id);
            $t->email = $me['mail'];
            $t->save();

I'm using the following check in the listener. Can this be added into the MsGraph code so that $t->email is set correctly?

if ($event->token['info']['mail']===null) { $email=$event->token['info']['userPrincipalName']; } else { $email=$event->token['info']['mail']; }

dcblogdev commented 2 years ago

Thanks for your suggestions, I've implemented this change.