@@ -19,26 +19,30 @@ class BindsLdapUserModel
19
19
*/
20
20
public function handle ($ event )
21
21
{
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
+ );
31
35
}
32
36
}
33
37
34
38
/**
35
39
* Determines if the Auth Provider is an instance of the Adldap Provider.
36
40
*
37
- * @param string $guard
41
+ * @param string|null $guard
38
42
*
39
43
* @return bool
40
44
*/
41
- protected function isUsingAdldapProvider ($ guard ) : bool
45
+ protected function isUsingAdldapProvider ($ guard = null ) : bool
42
46
{
43
47
return Auth::guard ($ guard )->getProvider () instanceof DatabaseUserProvider;
44
48
}
0 commit comments