From cfb9b732055cac819417128cc2ad320f25991843 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 11 May 2021 08:16:40 +0000 Subject: [PATCH] Store creation date --- src/Module/BaseApi.php | 3 ++- src/Module/OAuth/Token.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Module/BaseApi.php b/src/Module/BaseApi.php index 87d0838c5..739d400e3 100644 --- a/src/Module/BaseApi.php +++ b/src/Module/BaseApi.php @@ -28,6 +28,7 @@ use Friendica\Database\Database; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Network\HTTPException; +use Friendica\Util\DateTimeFormat; require_once __DIR__ . '/../../include/api.php'; @@ -218,7 +219,7 @@ class BaseApi extends BaseModule $code = bin2hex(openssl_random_pseudo_bytes(32)); $access_token = bin2hex(openssl_random_pseudo_bytes(32)); - $fields = ['application-id' => $application['id'], 'uid' => $uid, 'code' => $code, 'access_token' => $access_token]; + $fields = ['application-id' => $application['id'], 'uid' => $uid, 'code' => $code, 'access_token' => $access_token, 'created_at' => DateTimeFormat::utcNow(DateTimeFormat::MYSQL)]; if (!DBA::insert('application-token', $fields, Database::INSERT_UPDATE)) { return []; } diff --git a/src/Module/OAuth/Token.php b/src/Module/OAuth/Token.php index 3cb59a4c1..6e574a8af 100644 --- a/src/Module/OAuth/Token.php +++ b/src/Module/OAuth/Token.php @@ -61,6 +61,7 @@ class Token extends BaseApi DI::mstdnError()->RecordNotFound(); } - System::jsonExit(['access_token' => $token['access_token'], 'token_type' => 'Bearer', 'scope' => $application['scopes']]); + // @todo Use entity class + System::jsonExit(['access_token' => $token['access_token'], 'token_type' => 'Bearer', 'scope' => $application['scopes'], 'created_at' => $token['created_at']]); } }