Merge branch '1.5.x' into feat-improve-header-demo-values

This commit is contained in:
Luke B. Silver 2024-05-15 17:30:21 +01:00 committed by GitHub
commit 44ef0c365a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 25 deletions

View file

@ -1069,17 +1069,15 @@ App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
$domain = $request->getHostname(); $domain = $request->getHostname();
$protocol = $request->getProtocol(); $protocol = $request->getProtocol();
$params = $request->getParams();
$params['project'] = $projectId;
unset($params['projectId']);
$response $response
->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') ->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')
->addHeader('Pragma', 'no-cache') ->addHeader('Pragma', 'no-cache')
->redirect($protocol . '://' . $domain . '/v1/account/sessions/oauth2/' . $provider . '/redirect?' ->redirect($protocol . '://' . $domain . '/v1/account/sessions/oauth2/' . $provider . '/redirect?'
. \http_build_query([ . \http_build_query($params));
'project' => $projectId,
'code' => $code,
'state' => $state,
'error' => $error,
'error_description' => $error_description
]));
}); });
App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId') App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
@ -1102,17 +1100,15 @@ App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
$domain = $request->getHostname(); $domain = $request->getHostname();
$protocol = $request->getProtocol(); $protocol = $request->getProtocol();
$params = $request->getParams();
$params['project'] = $projectId;
unset($params['projectId']);
$response $response
->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') ->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')
->addHeader('Pragma', 'no-cache') ->addHeader('Pragma', 'no-cache')
->redirect($protocol . '://' . $domain . '/v1/account/sessions/oauth2/' . $provider . '/redirect?' ->redirect($protocol . '://' . $domain . '/v1/account/sessions/oauth2/' . $provider . '/redirect?'
. \http_build_query([ . \http_build_query($params));
'project' => $projectId,
'code' => $code,
'state' => $state,
'error' => $error,
'error_description' => $error_description
]));
}); });
App::get('/v1/account/sessions/oauth2/:provider/redirect') App::get('/v1/account/sessions/oauth2/:provider/redirect')
@ -1239,7 +1235,17 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
$failureRedirect(Exception::USER_MISSING_ID); $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); $email = $oauth2->getUserEmail($accessToken);
// Check if this identity is connected to a different user // Check if this identity is connected to a different user

View file

@ -70,7 +70,7 @@ App::get('/v1/project/usage')
'1d' => 'Y-m-d\T00:00:00.000P', '1d' => 'Y-m-d\T00:00:00.000P',
}; };
Authorization::skip(function () use ($dbForProject, $firstDay, $lastDay, $period, $metrics, &$total, &$stats) { Authorization::skip(function () use ($dbForProject, $firstDay, $lastDay, $period, $metrics, $limit, &$total, &$stats) {
foreach ($metrics['total'] as $metric) { foreach ($metrics['total'] as $metric) {
$result = $dbForProject->findOne('stats', [ $result = $dbForProject->findOne('stats', [
Query::equal('metric', [$metric]), Query::equal('metric', [$metric]),
@ -85,6 +85,7 @@ App::get('/v1/project/usage')
Query::equal('period', [$period]), Query::equal('period', [$period]),
Query::greaterThanEqual('time', $firstDay), Query::greaterThanEqual('time', $firstDay),
Query::lessThan('time', $lastDay), Query::lessThan('time', $lastDay),
Query::limit($limit),
Query::orderDesc('time'), Query::orderDesc('time'),
]); ]);

View file

@ -160,15 +160,6 @@ class Apple extends OAuth2
*/ */
public function getUserName(string $accessToken): string public function getUserName(string $accessToken): string
{ {
if (
isset($this->claims['email']) &&
!empty($this->claims['email']) &&
isset($this->claims['email_verified']) &&
$this->claims['email_verified'] === 'true'
) {
return $this->claims['email'];
}
return ''; return '';
} }