From 17af87202a05da36312778476d36517dcf385918 Mon Sep 17 00:00:00 2001 From: Nadar Date: Thu, 30 Nov 2023 12:04:24 +0000 Subject: [PATCH] added apiUserTrackLastActivity --- CHANGELOG.md | 1 + src/Module.php | 7 +++++++ src/models/User.php | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7063ec998..624cd30e3 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ In order to read more about upgrading and BC breaks have a look at the [UPGRADE ## 5.0.1 + [#748](https://github.com/luyadev/luya-module-admin/pull/748) Do not clean up user lockouts when the user is an API-based user. This will enhance the performance for API user requests. ++ [#749]() Added a new property, `luya\admin\Module::$apiUserTrackLastActivity`, which controls the update of the last activity timestamp for API users. By default, this feature is enabled to maintain backward compatibility. For larger systems, disabling this property can prevent unnecessary database writes. ## 5.0.0 (30. November 2023) diff --git a/src/Module.php b/src/Module.php index 01014f022..680ad9ebe 100644 --- a/src/Module.php +++ b/src/Module.php @@ -337,6 +337,13 @@ final class Module extends \luya\admin\base\Module implements CoreModuleInterfac */ public $filterOpenApiPaths = []; + /** + * @var boolean This property, when enabled, triggers the update of the api_last_activity timestamp with each API request made by the specified API user. However, in systems + * that experience a high volume of API requests, this feature can potentially impact system performance. + * @since 5.0.1 + */ + public $apiUserTrackLastActivity = true; + /** * @inheritDoc */ diff --git a/src/models/User.php b/src/models/User.php index 889baede9..3a8eafa1e 100644 --- a/src/models/User.php +++ b/src/models/User.php @@ -567,7 +567,7 @@ public static function findIdentityByAccessToken($token, $type = null) } // if the given user can be found, udpate the api last activity timestamp. - if ($user) { + if ($user && Module::getInstance()->apiUserTrackLastActivity) { $user->updateAttributes(['api_last_activity' => time()]); }