Skip to content

Commit

Permalink
Merge pull request nextcloud#33293 from nextcloud/last-login-minute
Browse files Browse the repository at this point in the history
only update last login timestamp with minute percision
  • Loading branch information
PVince81 authored Jul 21, 2022
2 parents 33a9c7f + 9e34a21 commit afedfad
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/private/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,15 @@ public function getLastLogin() {
* updates the timestamp of the most recent login of this user
*/
public function updateLastLoginTimestamp() {
$firstTimeLogin = ($this->getLastLogin() === 0);
$this->lastLogin = time();
$this->config->setUserValue(
$this->uid, 'login', 'lastLogin', (string)$this->lastLogin);
$previousLogin = $this->getLastLogin();
$now = time();
$firstTimeLogin = $previousLogin === 0;

if ($now - $previousLogin > 60) {
$this->lastLogin = time();
$this->config->setUserValue(
$this->uid, 'login', 'lastLogin', (string)$this->lastLogin);
}

return $firstTimeLogin;
}
Expand Down

0 comments on commit afedfad

Please sign in to comment.