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

Commit 81b36ab

Browse files
committed
Extend from the EloquentUserProvider
1 parent 67ce234 commit 81b36ab

File tree

1 file changed

+5
-105
lines changed

1 file changed

+5
-105
lines changed

src/Auth/DatabaseUserProvider.php

Lines changed: 5 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Adldap\Laravel\Facades\Resolver;
77
use Adldap\Laravel\Commands\Import;
88
use Adldap\Laravel\Commands\SyncPassword;
9+
use Adldap\Laravel\Traits\ValidatesUsers;
910
use Adldap\Laravel\Events\Imported;
1011
use Adldap\Laravel\Events\AuthenticationRejected;
1112
use Adldap\Laravel\Events\AuthenticationSuccessful;
@@ -14,32 +15,11 @@
1415
use Illuminate\Support\Facades\Bus;
1516
use Illuminate\Support\Facades\Config;
1617
use Illuminate\Auth\EloquentUserProvider;
17-
use Illuminate\Contracts\Hashing\Hasher;
18-
use Illuminate\Contracts\Auth\UserProvider;
1918
use Illuminate\Contracts\Auth\Authenticatable;
2019

21-
class DatabaseUserProvider extends Provider
20+
class DatabaseUserProvider extends EloquentUserProvider
2221
{
23-
/**
24-
* The hasher implementation.
25-
*
26-
* @var \Illuminate\Contracts\Hashing\Hasher
27-
*/
28-
protected $hasher;
29-
30-
/**
31-
* The Eloquent user model.
32-
*
33-
* @var string
34-
*/
35-
protected $model;
36-
37-
/**
38-
* The fallback user provider.
39-
*
40-
* @var UserProvider
41-
*/
42-
protected $fallback;
22+
use ValidatesUsers;
4323

4424
/**
4525
* The currently authenticated LDAP user.
@@ -48,49 +28,6 @@ class DatabaseUserProvider extends Provider
4828
*/
4929
protected $user;
5030

51-
/**
52-
* Constructor.
53-
*
54-
* @param Hasher $hasher
55-
* @param string $model
56-
*/
57-
public function __construct(Hasher $hasher, $model)
58-
{
59-
$this->model = $model;
60-
$this->hasher = $hasher;
61-
62-
$this->setFallback(new EloquentUserProvider($hasher, $model));
63-
}
64-
65-
/**
66-
* {@inheritdoc}
67-
*/
68-
public function retrieveById($identifier)
69-
{
70-
return $this->fallback->retrieveById($identifier);
71-
}
72-
73-
/**
74-
* {@inheritdoc}
75-
*/
76-
public function retrieveByToken($identifier, $token)
77-
{
78-
return $this->fallback->retrieveByToken($identifier, $token);
79-
}
80-
81-
/**
82-
* Update the "remember me" token for the given user in storage.
83-
*
84-
* @param Authenticatable $user
85-
* @param string $token
86-
*
87-
* @return void
88-
*/
89-
public function updateRememberToken(Authenticatable $user, $token)
90-
{
91-
$this->fallback->updateRememberToken($user, $token);
92-
}
93-
9431
/**
9532
* {@inheritdoc}
9633
*/
@@ -112,7 +49,7 @@ public function retrieveByCredentials(array $credentials)
11249
}
11350

11451
if ($this->isFallingBack()) {
115-
return $this->fallback->retrieveByCredentials($credentials);
52+
return parent::retrieveByCredentials($credentials);
11653
}
11754
}
11855

@@ -159,49 +96,12 @@ public function validateCredentials(Authenticatable $model, array $credentials)
15996
if ($this->isFallingBack() && $model->exists) {
16097
// If the user exists in our local database already and fallback is
16198
// enabled, we'll perform standard eloquent authentication.
162-
return $this->fallback->validateCredentials($model, $credentials);
99+
return parent::validateCredentials($model, $credentials);
163100
}
164101

165102
return false;
166103
}
167104

168-
/**
169-
* Set the fallback user provider.
170-
*
171-
* @param UserProvider $provider
172-
*
173-
* @return void
174-
*/
175-
public function setFallback(UserProvider $provider)
176-
{
177-
$this->fallback = $provider;
178-
}
179-
180-
/**
181-
* Create a new instance of the model.
182-
*
183-
* @return \Illuminate\Database\Eloquent\Model
184-
*/
185-
public function createModel()
186-
{
187-
$class = '\\'.ltrim($this->model, '\\');
188-
189-
return new $class;
190-
}
191-
192-
/**
193-
* Perform all missing method calls on the underlying EloquentUserProvider fallback.
194-
*
195-
* @param string $name
196-
* @param array $arguments
197-
*
198-
* @return mixed
199-
*/
200-
public function __call($name, $arguments)
201-
{
202-
return call_user_func_array([$this->fallback, $name], $arguments);
203-
}
204-
205105
/**
206106
* Determines if login fallback is enabled.
207107
*

0 commit comments

Comments
 (0)