diff options
author | Vincent Petry <vincent@nextcloud.com> | 2022-07-21 09:41:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-21 09:41:21 +0200 |
commit | afedfad4990af207be426e46750c9b3b07651e48 (patch) | |
tree | 92bf4f12ba35c9974951a06e94d782f2f5b3cc9a | |
parent | 33a9c7ff266f1aa6c73f362d0d9c7f7a70273fb3 (diff) | |
parent | 9e34a2112920c89ed531291b52065e4421ed071d (diff) | |
download | nextcloud-server-afedfad4990af207be426e46750c9b3b07651e48.tar.gz nextcloud-server-afedfad4990af207be426e46750c9b3b07651e48.zip |
Merge pull request #33293 from nextcloud/last-login-minute
only update last login timestamp with minute percision
-rw-r--r-- | lib/private/User/User.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/private/User/User.php b/lib/private/User/User.php index c5306d1df27..7f7d6273e30 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -244,10 +244,15 @@ class User implements IUser { * 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; } |