Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing non-existent credentials should return null user #220

Merged
merged 2 commits into from
Feb 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/Zizaco/Confide/Confide.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ public function logAttempt( $credentials, $confirmed_only = false, $identity_col
array_keys($credentials),
array('password','remember')
);
// Recheck if identity_columns are populated now
if (empty($identity_columns)) {
return false;
}
}

// Check for throttle limit then log-in
Expand Down
4 changes: 4 additions & 0 deletions src/Zizaco/Confide/ConfideEloquentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ public function getUserByIdentity( $credentials, $identityColumns = array('email
$user = $user->orWhere($attribute, $credentials[$attribute]);
}
}
else
{
return null;
}
}

$user = $user->get();
Expand Down
5 changes: 5 additions & 0 deletions tests/ConfideEloquentRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ public function testShouldGetByIdentity()
$this->assertEquals(
null, $this->repo->getUserByIdentity( array() )
);

// When passing credentials that don't exist should return null
$this->assertEquals(
null, $this->repo->getUserByIdentity( array('token' => 'random-token-value') )
);
}

public function testShouldGetPasswordRemindersCountByToken()
Expand Down
7 changes: 0 additions & 7 deletions tests/ConfideTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,6 @@ public function testShouldLogAttempt()
$this->assertTrue(
$this->confide->logAttempt( $credentials, true )
);

unset($credentials['username']);
unset($credentials['email']);
// Should not login because there is no username or email provided
$this->assertFalse(
$this->confide->logAttempt( $credentials, true )
);
}

public function testShouldThrottleLogAttempt()
Expand Down