Skip to content

Commit

Permalink
throw an exception on registration with an empty password
Browse files Browse the repository at this point in the history
fixes cartalyst#51

Signed-off-by: Suhayb Wardany <me@suw.me>
  • Loading branch information
suwardany committed May 22, 2015
1 parent 7e623e5 commit c8b2591
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Users/IlluminateUserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ protected function validateUser(array $credentials, $id = null)
throw new InvalidArgumentException('No [login] credential was passed.');
}

if ($password === null)
if (empty($password))
{
throw new InvalidArgumentException('You have not passed a [password].');
}
Expand Down
17 changes: 17 additions & 0 deletions tests/IlluminateUserRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,23 @@ public function testValidateUserForCreationWithoutPassword()
$users->validForCreation($credetials);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testValidateUserForCreationWithEmptyPassword()
{
$user = new EloquentUser;

list($users, $hasher, $model, $query) = $this->getUsersMock();

$credetials = [
'email' => 'foo@example.com',
'password' => null,
];

$users->validForCreation($credetials);
}

public function testValidateUserForUpdate()
{
$user = $this->fakeUser();
Expand Down

0 comments on commit c8b2591

Please sign in to comment.