Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cater for both Carbon v2 and v3 - issue #260 #261

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
laravel: 11.*
stability: prefer-stable
coverage: xdebug
- php: 8.3
laravel: 11.*
carbon: 3.*

name: 'P${{ matrix.php }} L${{ matrix.laravel }} ${{ matrix.stability }} c:${{ matrix.coverage }}'

Expand Down Expand Up @@ -55,6 +58,11 @@ jobs:
run: |
composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-progress --no-update

- name: Set carbon version
if: ${{ matrix.carbon }}
run: |
composer require "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-progress --no-update

- name: Cache dependencies
uses: actions/cache@v4
with:
Expand Down
9 changes: 8 additions & 1 deletion src/Blacklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@ protected function getMinutesUntilExpired(Payload $payload)
// get the latter of the two expiration dates and find
// the number of minutes until the expiration date,
// plus 1 minute to avoid overlap
return round($exp->max($iat->addMinutes($this->refreshTTL))->addMinute()->diffInRealMinutes(null, true));
$intermediateResult = $exp->max($iat->addMinutes($this->refreshTTL))->addMinute();

// Handle Carbon 2 vs 3 deprecation of "Real" diff functions, see https://github.com/PHP-Open-Source-Saver/jwt-auth/issues/260
if (method_exists($intermediateResult, 'diffInRealMinutes')) {
return round($intermediateResult->diffInRealMinutes(null, true));
} else {
return (int) round($intermediateResult->diffInMinutes(null, true));
}
}

/**
Expand Down
Loading