1
0
Fork 0
mirror of synced 2024-06-14 00:34:51 +12:00

feat(auth): try to get user name from request param if not from oauth2

This is only applicable for Apple OAuth2 because this is the only
provider that does not return user name from an API call and only
returns the name in the callback URL.

Reference:
* https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_js/incorporating_sign_in_with_apple_into_other_platforms#3332115
This commit is contained in:
Steven Nguyen 2024-05-08 17:51:45 +00:00 committed by Steven Nguyen
parent df064adce3
commit c76e29077c
No known key found for this signature in database

View file

@ -1235,7 +1235,17 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
$failureRedirect(Exception::USER_MISSING_ID);
}
$name = $oauth2->getUserName($accessToken);
$name = '';
$nameOAuth = $oauth2->getUserName($accessToken);
$userParam = \json_decode($request->getParam('user'), true);
if (!empty($nameOAuth)) {
$name = $nameOAuth;
} elseif (is_array($userParam)) {
$nameParam = $userParam['name'];
if (is_array($nameParam) && isset($nameParam['firstName']) && isset($nameParam['lastName'])) {
$name = $nameParam['firstName'] . ' ' . $nameParam['lastName'];
}
}
$email = $oauth2->getUserEmail($accessToken);
// Check if this identity is connected to a different user