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

Commit e7c2ae0

Browse files
committed
Added override-able method to perform more authenticated tasks
- Closes #123
1 parent 798e53a commit e7c2ae0

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/AdldapAuthUserProvider.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ public function retrieveByCredentials(array $credentials)
5353
$password = $this->getPasswordFromCredentials($credentials);
5454

5555
// Construct / retrieve the eloquent model from our Adldap user.
56-
return $this->getModelFromAdldap($user, $password);
56+
$model = $this->getModelFromAdldap($user, $password);
57+
58+
// Perform other authenticated tasks.
59+
$this->handleAuthenticatedWithCredentials($user, $model);
60+
61+
return $model;
5762
}
5863

5964
if ($this->getLoginFallback()) {
@@ -85,6 +90,21 @@ public function validateCredentials(Authenticatable $user, array $credentials)
8590
return false;
8691
}
8792

93+
/**
94+
* Handle an authenticated LDAP user with their model.
95+
*
96+
* This method exists to be overridden.
97+
*
98+
* @param \Adldap\Models\User $user
99+
* @param Authenticatable $model
100+
*
101+
* @return void
102+
*/
103+
protected function handleAuthenticatedWithCredentials(User $user, $model)
104+
{
105+
//
106+
}
107+
88108
/**
89109
* Retrieves the Adldap User model from the specified Laravel model.
90110
*
@@ -94,7 +114,9 @@ public function validateCredentials(Authenticatable $user, array $credentials)
94114
*/
95115
protected function discoverAdldapFromModel($model)
96116
{
97-
if ($model instanceof Authenticatable && $this->getBindUserToModel()) {
117+
if ($this->getBindUserToModel()) {
118+
// If the developer wants to bind the Adldap User model
119+
// to the Laravel model, we'll query to find it.
98120
$attributes = $this->getUsernameAttribute();
99121

100122
$key = key($attributes);

0 commit comments

Comments
 (0)