From faf1d83e393853c5da5c139a31fd3ebdd75735ef Mon Sep 17 00:00:00 2001 From: Rafael Sorto Date: Fri, 31 Jan 2025 10:04:14 -0600 Subject: [PATCH] includeExpired set to false should not automatically return null for a session --- src/Auth/Session.php | 4 ++-- src/Utils.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Auth/Session.php b/src/Auth/Session.php index 8d86d23d..953971ce 100644 --- a/src/Auth/Session.php +++ b/src/Auth/Session.php @@ -145,11 +145,11 @@ public function clone(string $newSessionId): Session * * @return bool */ - public function isValid(): bool + public function isValid(bool $includeExpired = false): bool { return (Context::$SCOPES->equals($this->scope) && $this->accessToken && - (!$this->expires || ($this->expires > new DateTime())) + ($includeExpired || !$this->expires || ($this->expires > new DateTime())) ); } } diff --git a/src/Utils.php b/src/Utils.php index deaafa81..94d873e3 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -179,7 +179,7 @@ public static function loadOfflineSession(string $shop, bool $includeExpired = f $sessionId = OAuth::getOfflineSessionId($shop); $session = Context::$SESSION_STORAGE->loadSession($sessionId); - if ($session && !$includeExpired && !$session->isValid()) { + if ($session && !$session->isValid($includeExpired)) { return null; }