Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit 73c0229

Browse files
committed
Small tweaks.
1 parent c0454d8 commit 73c0229

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/AdldapAuthUserProvider.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@ public function retrieveByCredentials(array $credentials)
5050
// Get the input key.
5151
$key = key($attributes);
5252

53-
// Filter the query by the username attribute.
54-
$query->whereEquals($attributes[$key], $credentials[$key]);
55-
56-
// Retrieve the first user result.
57-
$user = $query->first();
53+
// Filter the query by the username attribute and retrieve the first user result.
54+
$user = $query->where([$attributes[$key] => $credentials[$key]])->first();
5855

5956
// If the user is an Adldap User model instance.
6057
if ($user instanceof User) {
@@ -101,11 +98,9 @@ protected function discoverAdldapFromModel($model)
10198

10299
$key = key($attributes);
103100

104-
$query = $this->newAdldapUserQuery();
105-
106-
$query->whereEquals($attributes[$key], $model->{$key});
107-
108-
$user = $query->first();
101+
$user = $this->newAdldapUserQuery()
102+
->where([$attributes[$key] => $model->{$key}])
103+
->first();
109104

110105
if ($user instanceof User) {
111106
$model = $this->bindAdldapToModel($user, $model);

tests/AdldapTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function test_auth_passes()
8585

8686
$mockedSearch->shouldReceive('users')->once()->andReturn($mockedSearch);
8787
$mockedSearch->shouldReceive('select')->once()->andReturn($mockedBuilder);
88-
$mockedBuilder->shouldReceive('whereEquals')->once()->andReturn($mockedBuilder);
88+
$mockedBuilder->shouldReceive('where')->once()->andReturn($mockedBuilder);
8989
$mockedBuilder->shouldReceive('first')->once()->andReturn($adUser);
9090
$mockedAuth->shouldReceive('attempt')->once()->andReturn(true);
9191

@@ -146,7 +146,7 @@ public function test_auth_fails()
146146

147147
$mockedSearch->shouldReceive('users')->once()->andReturn($mockedSearch);
148148
$mockedSearch->shouldReceive('select')->once()->andReturn($mockedBuilder);
149-
$mockedBuilder->shouldReceive('whereEquals')->once()->andReturn($mockedBuilder);
149+
$mockedBuilder->shouldReceive('where')->once()->andReturn($mockedBuilder);
150150
$mockedBuilder->shouldReceive('first')->once()->andReturn($adUser);
151151
$mockedAuth->shouldReceive('attempt')->once()->andReturn(false);
152152

@@ -174,7 +174,7 @@ public function test_auth_fails_when_user_not_found()
174174
$mockedSearch->shouldReceive('users')->once()->andReturn($mockedSearch);
175175
$mockedSearch->shouldReceive('select')->once()->andReturn($mockedBuilder);
176176
$mockedBuilder->shouldReceive('getConnection')->once()->andReturn($mockedConnection);
177-
$mockedBuilder->shouldReceive('whereEquals')->once()->andReturn($mockedBuilder);
177+
$mockedBuilder->shouldReceive('where')->once()->andReturn($mockedBuilder);
178178
$mockedBuilder->shouldReceive('first')->once()->andReturn(null);
179179

180180
$this->assertFalse(Auth::attempt(['email' => 'jdoe@email.com', 'password' => '12345']));
@@ -236,7 +236,7 @@ public function test_config_login_fallback()
236236
$mockedSearch->shouldReceive('users')->twice()->andReturn($mockedSearch);
237237
$mockedSearch->shouldReceive('select')->twice()->andReturn($mockedSearch);
238238
$mockedSearch->shouldReceive('getConnection')->twice()->andReturn($mockedConnection);
239-
$mockedSearch->shouldReceive('whereEquals')->twice()->andReturn($mockedSearch);
239+
$mockedSearch->shouldReceive('where')->twice()->andReturn($mockedSearch);
240240
$mockedSearch->shouldReceive('first')->twice()->andReturn(null);
241241

242242
$manager = new Manager();

0 commit comments

Comments
 (0)