diff --git a/.gitignore b/.gitignore index 8b7ef35..dfd6caa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /vendor -composer.lock +composer.lock \ No newline at end of file diff --git a/src/Confide/CacheLoginThrottleService.php b/src/Confide/CacheLoginThrottleService.php index 6927d56..48f5c04 100644 --- a/src/Confide/CacheLoginThrottleService.php +++ b/src/Confide/CacheLoginThrottleService.php @@ -75,9 +75,11 @@ protected function parseIdentity($identity) // If is an array, remove password, remember and then // transforms it into a string. if (is_array($identity)) { - unset($identity['password']); - unset($identity['remember']); - $identity = serialize($identity); + if (isset($identity['email'])) { + return $identity['email']; + } elseif (isset($identity['username'])) { + return $identity['username']; + } } return $identity; diff --git a/tests/Confide/CacheLoginThrottleServiceTest.php b/tests/Confide/CacheLoginThrottleServiceTest.php index de75464..6cb3f6c 100644 --- a/tests/Confide/CacheLoginThrottleServiceTest.php +++ b/tests/Confide/CacheLoginThrottleServiceTest.php @@ -67,10 +67,10 @@ public function testShouldCheckIsThrottled() */ $throttleService->shouldReceive('parseIdentity') ->once()->with($identity) - ->andReturn(serialize(['email'=>'someone@somewhere.com'])); + ->andReturn('someone@somewhere.com'); $throttleService->shouldReceive('countThrottle') - ->once()->with(serialize(['email'=>'someone@somewhere.com']), 0) + ->once()->with('someone@somewhere.com', 0) ->andReturn(10); // More than the limit specified bellow $config->shouldReceive('get') @@ -106,10 +106,10 @@ public function testShouldCheckIsThrottledOnNonThrottled() */ $throttleService->shouldReceive('parseIdentity') ->once()->with($identity) - ->andReturn(serialize(['email'=>'someone@somewhere.com'])); + ->andReturn('someone@somewhere.com'); $throttleService->shouldReceive('countThrottle') - ->once()->with(serialize(['email'=>'someone@somewhere.com']), 0) + ->once()->with('someone@somewhere.com', 0) ->andReturn(5); // Less than the limit specified bellow $config->shouldReceive('get') @@ -149,7 +149,7 @@ public function testShouldParseIdentity() |------------------------------------------------------------ */ $this->assertEquals( - serialize(['email'=>'someone@somewhere.com']), + 'someone@somewhere.com', $throttleService->parseIdentity($identity) ); }