Skip to content

Commit

Permalink
Get our tests passing again.
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnieezell committed Aug 29, 2019
1 parent d7b85f7 commit 0b53af3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/Authentication/AuthenticationBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function isLoggedIn(): bool
// Store our current user object
$this->user = $this->userModel->find($userID);

return true;
return $this->user instanceof User;
}

return false;
Expand Down
16 changes: 8 additions & 8 deletions src/Authentication/LocalAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ public function attempt(array $credentials, bool $remember = null): bool
}

if ($this->user->isBanned())
{
// Always record a login attempt, whether success or not.
$ipAddress = Services::request()->getIPAddress();
$this->recordLoginAttempt($credentials['email'], $ipAddress, $this->user->id ?? null, false);
$this->user = null;
return false;
}
{
// Always record a login attempt, whether success or not.
$ipAddress = Services::request()->getIPAddress();
$this->recordLoginAttempt($credentials['email'], $ipAddress, $this->user->id ?? null, false);

$this->user = null;
return false;
}

return $this->login($this->user, $remember);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static function authentication(string $lib = 'local', Model $userModel=nu
{
return self::getSharedInstance('authentication', $lib, $userModel, $loginModel);
}

// config() checks first in app/Config
$config = config('Auth');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use CodeIgniter\Database\Migration;

class Migration_create_auth_tables extends Migration
class CreateAuthTables extends Migration
{
public function up()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function unBan()
*/
public function isBanned(): bool
{
return $this->attributes['status'] === 'banned';
return isset($this->attributes['status']) && $this->attributes['status'] === 'banned';
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/authentication/LocalAuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function testValidateSuccess()

public function testCheckNotRemembered()
{
$_SESSION = [];
$user = $this->createUser();

$this->assertFalse($this->auth->check());
Expand Down

1 comment on commit 0b53af3

@MGatner
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.