Reformatted code

This commit is contained in:
Michael 2023-07-23 20:20:46 +00:00
parent 61af2e8006
commit 6fd4839441
2 changed files with 7 additions and 4 deletions

View File

@ -91,8 +91,10 @@ class Token extends BaseApi
} elseif ($request['grant_type'] == 'authorization_code') {
// For security reasons only allow freshly created tokens
$uri = new Uri($request['redirect_uri']);
$condition = ["`redirect_uri` LIKE ? AND `id` = ? AND `code` = ? AND `created_at` > ?",
'%' . $uri->getScheme() . '://' . $uri->getHost() . $uri->getPath() . '%', $application['id'], $request['code'], DateTimeFormat::utc('now - 5 minutes')];
$condition = [
"`redirect_uri` LIKE ? AND `id` = ? AND `code` = ? AND `created_at` > ?",
'%' . $uri->getScheme() . '://' . $uri->getHost() . $uri->getPath() . '%', $application['id'], $request['code'], DateTimeFormat::utc('now - 5 minutes')
];
$token = DBA::selectFirst('application-view', ['access_token', 'created_at', 'uid'], $condition);
if (!DBA::isResult($token)) {

View File

@ -146,7 +146,7 @@ class OAuth
if (($application['redirect_uri'] != $redirect_uri) && !in_array($redirect_uri, explode(' ', $application['redirect_uri']))) {
return [];
}
return $application;
}
@ -197,7 +197,8 @@ class OAuth
'write' => (stripos($scope, BaseApi::SCOPE_WRITE) !== false),
'follow' => (stripos($scope, BaseApi::SCOPE_FOLLOW) !== false),
'push' => (stripos($scope, BaseApi::SCOPE_PUSH) !== false),
'created_at' => DateTimeFormat::utcNow()];
'created_at' => DateTimeFormat::utcNow()
];
foreach ([BaseApi::SCOPE_READ, BaseApi::SCOPE_WRITE, BaseApi::SCOPE_WRITE, BaseApi::SCOPE_PUSH] as $scope) {
if ($fields[$scope] && !$application[$scope]) {