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

Commit 1092fb5

Browse files
committed
Moved getSchema and getAdldap to the ImportsUsers trait
1 parent 1b63ca6 commit 1092fb5

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

src/AdldapAuthUserProvider.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -319,35 +319,6 @@ protected function handleAttributeRetrieval(User $user, $field)
319319
return $value;
320320
}
321321

322-
/**
323-
* Returns Adldap's current attribute schema.
324-
*
325-
* @return \Adldap\Contracts\Schemas\SchemaInterface
326-
*/
327-
protected function getSchema()
328-
{
329-
return $this->getAdldap()->getSchema();
330-
}
331-
332-
/**
333-
* Returns the root Adldap instance.
334-
*
335-
* @param string $provider
336-
*
337-
* @return \Adldap\Contracts\Connections\ProviderInterface
338-
*/
339-
protected function getAdldap($provider = null)
340-
{
341-
/** @var \Adldap\Adldap $ad */
342-
$ad = Adldap::getFacadeRoot();
343-
344-
if (is_null($provider)) {
345-
$provider = $this->getDefaultConnectionName();
346-
}
347-
348-
return $ad->getManager()->get($provider);
349-
}
350-
351322
/**
352323
* Returns the password key to retrieve the
353324
* password from the user input array.

src/Middleware/WindowsAuthenticate.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Adldap\Laravel\Traits\ImportsUsers;
66
use Adldap\Models\User;
7-
use Adldap\Schemas\ActiveDirectory;
87
use Closure;
98
use Illuminate\Contracts\Auth\Guard;
109
use Illuminate\Database\Eloquent\Model;
@@ -119,6 +118,6 @@ public function createModel()
119118
*/
120119
protected function getWindowsAuthAttribute()
121120
{
122-
return Config::get('adldap_auth.windows_auth_attribute', [ActiveDirectory::ACCOUNT_NAME => 'AUTH_USER']);
121+
return Config::get('adldap_auth.windows_auth_attribute', [$this->getSchema()->accountName() => 'AUTH_USER']);
123122
}
124123
}

src/Traits/ImportsUsers.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,35 @@ protected function newAdldapUserQuery()
220220
return $query->select($this->getSelectAttributes());
221221
}
222222

223+
/**
224+
* Returns Adldap's current attribute schema.
225+
*
226+
* @return \Adldap\Contracts\Schemas\SchemaInterface
227+
*/
228+
protected function getSchema()
229+
{
230+
return $this->getAdldap()->getSchema();
231+
}
232+
233+
/**
234+
* Returns the root Adldap instance.
235+
*
236+
* @param string $provider
237+
*
238+
* @return \Adldap\Contracts\Connections\ProviderInterface
239+
*/
240+
protected function getAdldap($provider = null)
241+
{
242+
/** @var \Adldap\Adldap $ad */
243+
$ad = Adldap::getFacadeRoot();
244+
245+
if (is_null($provider)) {
246+
$provider = $this->getDefaultConnectionName();
247+
}
248+
249+
return $ad->getManager()->get($provider);
250+
}
251+
223252
/**
224253
* Retrieves the Aldldap select attributes when performing
225254
* queries for authentication and binding for users.

0 commit comments

Comments
 (0)