@@ -19,26 +19,30 @@ class BindsLdapUserModel
1919 */
2020 public function handle ($ event )
2121 {
22- // Before we bind the users LDAP model, we will verify they are using the Adldap
23- // authentication provider, the required trait, the users LDAP property has
24- // not already been set, and we have located an LDAP user to bind.
25- if (
26- $ this ->isUsingAdldapProvider ($ event ->guard )
27- && $ this ->canBind ($ event ->user )
28- && $ user = Resolver::byModel ($ event ->user )
29- ) {
30- $ event ->user ->setLdapUser ($ user );
22+ $ guard = null ;
23+
24+ // We'll retrieve the auth guard if available.
25+ if (property_exists ($ event , 'guard ' )) {
26+ $ guard = $ event ->guard ;
27+ }
28+
29+ // Before we bind the users LDAP model, we will verify they are using
30+ // the Adldap authentication provider, and the required trait.
31+ if ($ this ->isUsingAdldapProvider ($ guard ) && $ this ->canBind ($ event ->user )) {
32+ $ event ->user ->setLdapUser (
33+ Resolver::byModel ($ event ->user )
34+ );
3135 }
3236 }
3337
3438 /**
3539 * Determines if the Auth Provider is an instance of the Adldap Provider.
3640 *
37- * @param string $guard
41+ * @param string|null $guard
3842 *
3943 * @return bool
4044 */
41- protected function isUsingAdldapProvider ($ guard ) : bool
45+ protected function isUsingAdldapProvider ($ guard = null ) : bool
4246 {
4347 return Auth::guard ($ guard )->getProvider () instanceof DatabaseUserProvider;
4448 }
0 commit comments