@@ -121,31 +121,33 @@ public function retrieveByCredentials(array $credentials)
121
121
*/
122
122
public function validateCredentials (Authenticatable $ model , array $ credentials )
123
123
{
124
- // We'll check if we have an LDAP user, and then make sure
125
- // they pass authentication before going further.
126
- if (
127
- $ this ->user instanceof User &&
128
- Resolver::authenticate ($ this ->user , $ credentials )
129
- ) {
130
- Event::fire (new AuthenticatedWithCredentials ($ this ->user , $ model ));
131
-
132
- // Here we will perform authorization on the LDAP user. If all
133
- // validation rules pass, we will allow the authentication
134
- // attempt. Otherwise, it is automatically rejected.
135
- if ($ this ->passesValidation ($ this ->user , $ model )) {
136
- // Here we can now synchronize / set the users password since
137
- // they have successfully passed authentication
138
- // and our validation rules.
139
- Bus::dispatch (new SyncPassword ($ model , $ credentials ));
140
-
141
- $ model ->save ();
142
-
143
- Event::fire (new AuthenticationSuccessful ($ this ->user ));
144
-
145
- return true ;
124
+ if ($ this ->user instanceof User) {
125
+ // If an LDAP user was discovered, we can go
126
+ // ahead and try to authenticate them.
127
+ if (Resolver::authenticate ($ this ->user , $ credentials )) {
128
+ Event::fire (new AuthenticatedWithCredentials ($ this ->user , $ model ));
129
+
130
+ // Here we will perform authorization on the LDAP user. If all
131
+ // validation rules pass, we will allow the authentication
132
+ // attempt. Otherwise, it is automatically rejected.
133
+ if ($ this ->passesValidation ($ this ->user , $ model )) {
134
+ // Here we can now synchronize / set the users password since
135
+ // they have successfully passed authentication
136
+ // and our validation rules.
137
+ Bus::dispatch (new SyncPassword ($ model , $ credentials ));
138
+
139
+ $ model ->save ();
140
+
141
+ Event::fire (new AuthenticationSuccessful ($ this ->user ));
142
+
143
+ return true ;
144
+ }
145
+
146
+ Event::fire (new AuthenticationRejected ($ this ->user ));
146
147
}
147
148
148
- Event::fire (new AuthenticationRejected ($ this ->user ));
149
+ // LDAP Authentication failed.
150
+ return false ;
149
151
}
150
152
151
153
if ($ this ->isFallingBack () && $ model ->exists ) {
0 commit comments