diff --git a/.gitignore b/.gitignore index 22d0d82..0669f6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ vendor +.DS_Store \ No newline at end of file diff --git a/composer.json b/composer.json index 8bd68b4..b3c16c2 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "cube-php/auth", "description": "PHP Cube Authentication Package", "type": "package", - "version": "0.0.5", + "version": "0.0.6", "license": "MIT", "autoload": { "psr-4": { @@ -16,7 +16,7 @@ } ], "require": { - "cube-php/core": "^0.1.23", + "cube-php/core": "0.1.31", "firebase/php-jwt": "^6.10" }, "extra": { diff --git a/composer.lock b/composer.lock index 896bff8..bae070d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "dbea4369fc1bf6ee0a72fb4bc444b62b", + "content-hash": "3d5fd1b97ec382c68cd8bc796905c4ab", "packages": [ { "name": "cube-php/core", - "version": "0.1.23", + "version": "0.1.31", "source": { "type": "git", "url": "https://github.com/cube-php/core.git", - "reference": "38b12a94909d93d03aeca1fe741603a4f88f3c73" + "reference": "4837a4634bb28dd227d17bd2405681199920d976" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cube-php/core/zipball/38b12a94909d93d03aeca1fe741603a4f88f3c73", - "reference": "38b12a94909d93d03aeca1fe741603a4f88f3c73", + "url": "https://api.github.com/repos/cube-php/core/zipball/4837a4634bb28dd227d17bd2405681199920d976", + "reference": "4837a4634bb28dd227d17bd2405681199920d976", "shasum": "" }, "require": { @@ -49,9 +49,9 @@ "description": "PHP Cube core utilities", "support": { "issues": "https://github.com/cube-php/core/issues", - "source": "https://github.com/cube-php/core/tree/v0.1.23" + "source": "https://github.com/cube-php/core/tree/v0.1.31" }, - "time": "2024-08-15T16:47:14+00:00" + "time": "2025-08-16T16:49:52+00:00" }, { "name": "dammynex/pagenator", @@ -1523,10 +1523,10 @@ "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, - "platform": [], - "platform-dev": [], + "platform": {}, + "platform-dev": {}, "plugin-api-version": "2.6.0" } diff --git a/src/Auth.php b/src/Auth.php index b5e5c1d..11b5e6d 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -211,14 +211,15 @@ public static function getTokenFromRequest(Request $request, AuthTokenType $type /** * User * + * @param Request $request * @return ModelInterface|null */ - public static function user(): ?ModelInterface + public static function user(Request $request): ?ModelInterface { $auth_id = Session::get(self::$auth_name); if (!$auth_id) { - return self::getAuthUserFromCookie(); + return self::getAuthUserFromCookie($request); } $model = self::getConfigField(AuthConfig::MODEL); @@ -365,11 +366,12 @@ public static function jwtFor(ModelInterface $user, array $options = array()): A /** * Get authenticated user from session * + * @param Request $request * @return ModelInterface|null */ - protected static function getAuthUserFromCookie(): ?ModelInterface + protected static function getAuthUserFromCookie(Request $request): ?ModelInterface { - $auth_id = Cookie::get(self::$auth_name); + $auth_id = Cookie::get($request, self::$auth_name); if (!$auth_id) { return null;