Skip to content

Commit

Permalink
check possible inconsistent data webflow response
Browse files Browse the repository at this point in the history
  • Loading branch information
tcampbPPU committed Nov 18, 2022
1 parent dac82cd commit 22b8cf7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/SocialiteWebflowProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,15 @@ protected function getUserByToken($token)
*/
protected function mapUserToObject(array $user)
{
// check names since data doesn't always looks consistent
$firstName = isset($user['firstName']) ? $user['firstName'] : '';
$lastName = isset($user['lastName']) ? $user['lastName'] : '';
$name = $firstName . ' ' . $lastName;

return (new User())->setRaw($user)->map([
'id' => $user['_id'],
'nickname' => null,
'name' => $user['firstName'] . ' ' . $user['lastName'],
'name' => $name,
'email' => $user['email'],
'avatar' => 'https://www.gravatar.com/avatar/' . md5($user['email']),
]);
Expand Down

0 comments on commit 22b8cf7

Please sign in to comment.