This repository was archived by the owner on Jul 24, 2023. It is now read-only.
File tree 2 files changed +12
-4
lines changed
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 12
12
use Illuminate \Support \Facades \Config ;
13
13
use Illuminate \Support \ServiceProvider ;
14
14
use Illuminate \Contracts \Hashing \Hasher ;
15
+ use Illuminate \Auth \Events \Login ;
15
16
use Illuminate \Auth \Events \Authenticated ;
16
17
17
18
class AdldapAuthServiceProvider extends ServiceProvider
@@ -63,6 +64,7 @@ public function register()
63
64
// model to their Eloquent model upon authentication (if configured).
64
65
// This allows us to utilize their LDAP model right
65
66
// after authentication has passed.
67
+ Event::listen (Login::class, Listeners \BindsLdapUserModel::class);
66
68
Event::listen (Authenticated::class, Listeners \BindsLdapUserModel::class);
67
69
68
70
if ($ this ->isLogging ()) {
Original file line number Diff line number Diff line change 6
6
use Adldap \Laravel \Facades \Resolver ;
7
7
use Adldap \Laravel \Traits \HasLdapUser ;
8
8
use Illuminate \Support \Facades \Auth ;
9
- use Illuminate \Auth \Events \Authenticated ;
10
9
use Illuminate \Contracts \Auth \Authenticatable ;
11
10
12
11
class BindsLdapUserModel
13
12
{
14
13
/**
15
14
* Binds the LDAP user record to their model.
16
15
*
17
- * @param Authenticated $event
16
+ * @param mixed $event
18
17
*
19
18
* @return void
20
19
*/
21
- public function handle (Authenticated $ event )
20
+ public function handle ($ event )
22
21
{
23
- if ($ this ->isUsingAdldapProvider () && $ this ->canBind ($ event ->user )) {
22
+ // Before we bind the users LDAP model, we will verify they are using the
23
+ // Adldap authentication provider, the required trait, and the
24
+ // users LDAP property has not already been set.
25
+ if (
26
+ $ this ->isUsingAdldapProvider ()
27
+ && $ this ->canBind ($ event ->user )
28
+ && is_null ($ event ->user ->ldap )
29
+ ) {
24
30
$ event ->user ->setLdapUser (
25
31
Resolver::byModel ($ event ->user )
26
32
);
You can’t perform that action at this time.
0 commit comments