From 74e58266b54866d3c4ed7261d78401d8a4c30935 Mon Sep 17 00:00:00 2001 From: Agung Sugiarto Date: Sat, 15 Oct 2022 13:16:29 +0700 Subject: [PATCH] Fix InvalidArgumentException when logging in (#35) * Fix InvalidArgumentException when logging in * remove unused package --- composer.json | 5 +---- src/Controllers/Auth/AuthenticatedSessionController.php | 4 +--- src/Filters/ThrottleFilter.php | 4 +--- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 5faab54..d909727 100644 --- a/composer.json +++ b/composer.json @@ -21,8 +21,7 @@ }, "require-dev": { "fakerphp/faker": "^1.13", - "phpunit/phpunit": "^9.1", - "laminas/laminas-coding-standard": "^2.1" + "phpunit/phpunit": "^9.1" }, "autoload": { "psr-4": { @@ -48,8 +47,6 @@ "minimum-stability": "dev", "prefer-stable": true, "scripts": { - "cs-check": "phpcs", - "cs-fix": "phpcbf", "test": "phpunit" } } diff --git a/src/Controllers/Auth/AuthenticatedSessionController.php b/src/Controllers/Auth/AuthenticatedSessionController.php index 96a0ee1..d38ca02 100644 --- a/src/Controllers/Auth/AuthenticatedSessionController.php +++ b/src/Controllers/Auth/AuthenticatedSessionController.php @@ -7,12 +7,10 @@ use CodeIgniter\View\RendererInterface; use Fluent\Auth\Facades\Auth; use Fluent\Auth\Facades\RateLimiter; -use Fluent\Auth\Helpers\Str; use function func_get_args; use function is_array; use function is_bool; -use function strtolower; use function trim; class AuthenticatedSessionController extends BaseController @@ -136,6 +134,6 @@ protected function isEmptyString($key) */ public function throttleKey() { - return strtolower(Str::extractName($this->request->getPost('email'))) . '_' . str_replace("::", "", $this->request->getIPAddress()); + return md5("{$this->request->getPost('email')}|{$this->request->getIPAddress()}"); } } diff --git a/src/Filters/ThrottleFilter.php b/src/Filters/ThrottleFilter.php index dab59ea..469ab5b 100644 --- a/src/Filters/ThrottleFilter.php +++ b/src/Filters/ThrottleFilter.php @@ -8,9 +8,7 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\Response; use CodeIgniter\HTTP\ResponseInterface; -use Fluent\Auth\Facades\Auth; use Fluent\Auth\Facades\RateLimiter; -use Fluent\Auth\Helpers\Str; use function array_values; @@ -88,6 +86,6 @@ protected function decaySecond(array $arguments) */ public function throttleKey(RequestInterface $request) { - return 'throttle_' . Str::extractName(Auth::user()->email) . '_' . str_replace("::", "", $request->getIPAddress()); + return 'throttle_' . md5(auth()->user()->email . "|{$request->getIPAddress()}"); } }