Skip to content

Commit

Permalink
fix: patch up ?? throw for 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Oct 31, 2024
1 parent fb68b70 commit 55d02bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/Auth/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@ public function __construct($data)
Session::set('auth.user', $this->get());

if ($sessionLifetime !== 0 && $sessionLifetime !== null) {
Session::set(
'auth.ttl',
is_int($sessionLifetime)
? time() + $sessionLifetime
: strtotime($sessionLifetime) ?? throw new \Exception('Invalid session lifetime')
);
if (!is_int($sessionLifetime)) {
$sessionLifetime = strtotime($sessionLifetime);

if (!$sessionLifetime) {
throw new \Exception('Invalid session lifetime');
}
} else {
$sessionLifetime = time() + $sessionLifetime;
}

Session::set('auth.ttl', $sessionLifetime);
}
}

Expand Down
1 change: 1 addition & 0 deletions tests/update.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

beforeAll(function () {
$auth = authInstance();
$auth->config(['db.table' => 'users']);

$auth->register([
'username' => 'test-user-1',
Expand Down

0 comments on commit 55d02bd

Please sign in to comment.