Skip to content

Commit

Permalink
[Apple] Add support for a user as an associative array in Apple provi…
Browse files Browse the repository at this point in the history
…der (#644)

Co-authored-by: Marco Marassi <[email protected]>
  • Loading branch information
thtg88 and thtg88 authored Mar 25, 2021
1 parent 01638dd commit 3a62620
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,15 @@ public function user()
*/
protected function mapUserToObject(array $user)
{
$value = trim((string) $this->request->input('user'));

if ($value !== '') {
$userRequest = json_decode($value, true);

if (isset($userRequest['name'])) {
$user['name'] = $userRequest['name'];
$fullName = trim(
($user['name']['firstName'] ?? '')
.' '
.($user['name']['lastName'] ?? '')
);
}
$userRequest = $this->getUserRequest();

if (isset($userRequest['name'])) {
$user['name'] = $userRequest['name'];
$fullName = trim(
($user['name']['firstName'] ?? '')
.' '
.($user['name']['lastName'] ?? '')
);
}

return (new User())
Expand All @@ -225,4 +221,21 @@ protected function mapUserToObject(array $user)
'email' => $user['email'] ?? null,
]);
}

private function getUserRequest(): array
{
$value = $this->request->input('user');

if (is_array($value)) {
return $value;
}

$value = trim((string) $value);

if ($value === '') {
return [];
}

return json_decode($value, true);
}
}

0 comments on commit 3a62620

Please sign in to comment.