diff --git a/app/Models/Auth/User.php b/app/Models/Auth/User.php index e81f19f..7ed6980 100644 --- a/app/Models/Auth/User.php +++ b/app/Models/Auth/User.php @@ -38,6 +38,15 @@ class User extends Authenticatable ]; } + public function jwtNeedsRefresh(int $refreshIntervalSeconds = 3600): bool + { + if (blank($this->user_jwt) || ! $this->user_jwt_issued_at) { + return true; + } + + return $this->user_jwt_issued_at->lte(now()->subSeconds($refreshIntervalSeconds)); + } + public function markPrivilegesChanged(): void { $this->increment('privileges_version');