Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Commit

Permalink
Removed unnecessary scope when retrieving users by the credential.
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGhostHunter committed Jul 3, 2020
1 parent 9d1e4d0 commit c83f063
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/WebAuthnAuthentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function allCredentialDescriptors() : array
public static function getFromCredentialId(string $id) : ?WebAuthnAuthenticatable
{
return static::whereHas('webAuthnCredentials', static function ($query) use ($id) {
return $query->whereKey($id)->enabled();
return $query->whereKey($id);
})->first();
}

Expand All @@ -184,7 +184,7 @@ public static function getFromCredentialId(string $id) : ?WebAuthnAuthenticatabl
public static function getFromCredentialUserHandle(string $handle) : ?WebAuthnAuthenticatable
{
return static::whereHas('webAuthnCredentials', static function ($query) use ($handle) {
return $query->where('user_handle', $handle)->enabled();
return $query->where('user_handle', $handle);
})->first();
}
}
11 changes: 11 additions & 0 deletions tests/WebAuthnAuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ public function test_returns_user_from_given_credential_id()
$this->assertTrue($this->user->is($user));

$this->assertNull(call_user_func([$this->user, 'getFromCredentialId'], 'test_credential_baz'));

DB::table('web_authn_credentials')->where('id', 'test_credential_foo')
->update(['disabled_at' => now()]);

$this->assertNull(call_user_func([$this->user, 'getFromCredentialId'], 'test_credential_foo'));
}

public function test_returns_user_from_given_user_handle()
Expand All @@ -285,5 +290,11 @@ public function test_returns_user_from_given_user_handle()
$this->assertTrue($this->user->is($user));

$this->assertNull(call_user_func([$this->user, 'getFromCredentialUserHandle'], 'nope'));

DB::table('web_authn_credentials')->update(['disabled_at' => now()]);

$this->assertNull(
call_user_func([$this->user, 'getFromCredentialUserHandle'], $this->user->userHandle())
);
}
}

0 comments on commit c83f063

Please sign in to comment.