diff --git a/framework/core/src/Api/Middleware/LoginWithHeader.php b/framework/core/src/Api/Middleware/LoginWithHeader.php index 1b820decb..e8e7f78cc 100644 --- a/framework/core/src/Api/Middleware/LoginWithHeader.php +++ b/framework/core/src/Api/Middleware/LoginWithHeader.php @@ -23,8 +23,7 @@ class LoginWithHeader ($accessToken = AccessToken::where('id', $token)->first())) { $this->actor->setUser($user = $accessToken->user); - $user->last_seen_time = time(); - $user->save(); + $user->updateLastSeen()->save(); } return $next($request); diff --git a/framework/core/src/Core/Models/User.php b/framework/core/src/Core/Models/User.php index 9d8b66934..8bbab5c47 100755 --- a/framework/core/src/Core/Models/User.php +++ b/framework/core/src/Core/Models/User.php @@ -404,6 +404,13 @@ class User extends Model return $this; } + public function updateLastSeen() + { + $this->last_seen_time = time(); + + return $this; + } + /** * Check whether or not the user is an administrator. * diff --git a/framework/core/src/Web/Middleware/LoginWithCookie.php b/framework/core/src/Web/Middleware/LoginWithCookie.php index 69dace775..dd8f7acb1 100644 --- a/framework/core/src/Web/Middleware/LoginWithCookie.php +++ b/framework/core/src/Web/Middleware/LoginWithCookie.php @@ -19,6 +19,8 @@ class LoginWithCookie if (($token = $request->cookie('flarum_remember')) && ($accessToken = AccessToken::where('id', $token)->first())) { $this->actor->setUser($accessToken->user); + + $user->updateLastSeen()->save(); } return $next($request);