Repurposed OAuth frontend handling, store the scope

This commit is contained in:
Michael 2021-05-13 14:58:55 +00:00
parent 132e08edb8
commit b18073d5a8
9 changed files with 121 additions and 139 deletions

View file

@ -267,9 +267,9 @@ class BaseApi extends BaseModule
$code = bin2hex(random_bytes(32));
$access_token = bin2hex(random_bytes(32));
// @todo store the scope
$fields = ['application-id' => $application['id'], 'uid' => $uid, 'code' => $code, 'access_token' => $access_token, 'created_at' => DateTimeFormat::utcNow(DateTimeFormat::MYSQL)];
$fields = ['application-id' => $application['id'], 'uid' => $uid, 'code' => $code, 'access_token' => $access_token, 'scopes' => $scope,
'read' => (stripos($scope, 'read') !== false), 'write' => (stripos($scope, 'write') !== false),
'follow' => (stripos($scope, 'follow') !== false), 'created_at' => DateTimeFormat::utcNow(DateTimeFormat::MYSQL)];
if (!DBA::insert('application-token', $fields, Database::INSERT_UPDATE)) {
return [];
}