Skip to content

Commit

Permalink
Merge pull request #612 from manageruz/develop
Browse files Browse the repository at this point in the history
Fixes issue with compatibility to work with CodeIgniter 4.4+
  • Loading branch information
manageruz committed Jan 11, 2024
2 parents 660f4e4 + 8847922 commit 564da94
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Authentication/AuthenticationBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Myth\Auth\Authentication;

use CodeIgniter\CodeIgniter;
use CodeIgniter\Events\Events;
use CodeIgniter\Model;
use Exception;
Expand Down Expand Up @@ -222,6 +223,16 @@ public function rememberUser(int $userID)
$appConfig = config('App');
$response = service('response');

// Replace cookie config values from cookie.php file on new versions of CI (v4.4.0 and above) for BC.
if (version_compare(CodeIgniter::CI_VERSION, '4.3.8', '>')) {

Check failure on line 227 in src/Authentication/AuthenticationBase.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 Static Analysis

If condition is always true.

Check failure on line 227 in src/Authentication/AuthenticationBase.php

View workflow job for this annotation

GitHub Actions / PHP 7.4 Static Analysis

If condition is always true.

Check failure on line 227 in src/Authentication/AuthenticationBase.php

View workflow job for this annotation

GitHub Actions / PHP 8.0 Static Analysis

If condition is always true.
$cookieConfig = config('Cookie');
$appConfig->cookieDomain = $cookieConfig->domain;
$appConfig->cookiePath = $cookieConfig->path;
$appConfig->cookiePrefix = $cookieConfig->prefix;
$appConfig->cookieSecure = $cookieConfig->secure;
$appConfig->cookieHTTPOnly = $cookieConfig->httponly;
}

// Create the cookie
$response->setCookie(
'remember', // Cookie Name
Expand Down Expand Up @@ -259,6 +270,16 @@ public function refreshRemember(int $userID, string $selector)

$appConfig = config('App');

// Replace cookie config values from cookie.php file on new versions of CI (v4.4.0 and above) for BC.
if (version_compare(CodeIgniter::CI_VERSION, '4.3.8', '>')) {

Check failure on line 274 in src/Authentication/AuthenticationBase.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 Static Analysis

If condition is always true.

Check failure on line 274 in src/Authentication/AuthenticationBase.php

View workflow job for this annotation

GitHub Actions / PHP 7.4 Static Analysis

If condition is always true.

Check failure on line 274 in src/Authentication/AuthenticationBase.php

View workflow job for this annotation

GitHub Actions / PHP 8.0 Static Analysis

If condition is always true.
$cookieConfig = config('Cookie');
$appConfig->cookieDomain = $cookieConfig->domain;
$appConfig->cookiePath = $cookieConfig->path;
$appConfig->cookiePrefix = $cookieConfig->prefix;
$appConfig->cookieSecure = $cookieConfig->secure;
$appConfig->cookieHTTPOnly = $cookieConfig->httponly;
}

// Create the cookie
set_cookie(
'remember', // Cookie Name
Expand Down

0 comments on commit 564da94

Please sign in to comment.