Skip to content

Commit

Permalink
only update last login timestamp with minute percision
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Jul 20, 2022
1 parent de08b53 commit 9e34a21
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 9e34a21

Please sign in to comment.