From 02929b9a09b03b0452dfc9ab5251f39ca3431ad8 Mon Sep 17 00:00:00 2001 From: Twaambo Haamucenje Date: Mon, 31 Jul 2023 17:58:38 +0200 Subject: [PATCH] Updates isExpired() check in TokenUtilTrait.php Makes use of Carbon to do some more reliable checking of token expiration. --- src/Traits/TokenUtilTrait.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Traits/TokenUtilTrait.php b/src/Traits/TokenUtilTrait.php index 0a96205..720b220 100644 --- a/src/Traits/TokenUtilTrait.php +++ b/src/Traits/TokenUtilTrait.php @@ -6,6 +6,8 @@ namespace Bmatovu\MtnMomo\Traits; +use Carbon\Carbon; + /** * Token model utilities. */ @@ -71,7 +73,9 @@ public function isExpired() if (is_null($this->expires_at)) { return false; } + $now = Carbon::now(); + $expiresAt = Carbon::parse($this->expires_at); - return $this->expires_at->isPast(); + return $now->isAfter($expiresAt); } }