@@ -53,7 +53,12 @@ public function retrieveByCredentials(array $credentials)
53
53
$ password = $ this ->getPasswordFromCredentials ($ credentials );
54
54
55
55
// 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 ;
57
62
}
58
63
59
64
if ($ this ->getLoginFallback ()) {
@@ -85,6 +90,21 @@ public function validateCredentials(Authenticatable $user, array $credentials)
85
90
return false ;
86
91
}
87
92
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
+
88
108
/**
89
109
* Retrieves the Adldap User model from the specified Laravel model.
90
110
*
@@ -94,7 +114,9 @@ public function validateCredentials(Authenticatable $user, array $credentials)
94
114
*/
95
115
protected function discoverAdldapFromModel ($ model )
96
116
{
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.
98
120
$ attributes = $ this ->getUsernameAttribute ();
99
121
100
122
$ key = key ($ attributes );
0 commit comments