Skip to content

Commit

Permalink
added apiUserTrackLastActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Nov 30, 2023
1 parent 2c2cfb9 commit 17af872
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 7 additions & 0 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion src/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()]);
}

Expand Down

0 comments on commit 17af872

Please sign in to comment.