This repository was archived by the owner on Jul 24, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 1212use Illuminate \Support \Facades \Config ;
1313use Illuminate \Support \ServiceProvider ;
1414use Illuminate \Contracts \Hashing \Hasher ;
15+ use Illuminate \Auth \Events \Login ;
1516use Illuminate \Auth \Events \Authenticated ;
1617
1718class AdldapAuthServiceProvider extends ServiceProvider
@@ -63,6 +64,7 @@ public function register()
6364 // model to their Eloquent model upon authentication (if configured).
6465 // This allows us to utilize their LDAP model right
6566 // after authentication has passed.
67+ Event::listen (Login::class, Listeners \BindsLdapUserModel::class);
6668 Event::listen (Authenticated::class, Listeners \BindsLdapUserModel::class);
6769
6870 if ($ this ->isLogging ()) {
Original file line number Diff line number Diff line change 66use Adldap \Laravel \Facades \Resolver ;
77use Adldap \Laravel \Traits \HasLdapUser ;
88use Illuminate \Support \Facades \Auth ;
9- use Illuminate \Auth \Events \Authenticated ;
109use Illuminate \Contracts \Auth \Authenticatable ;
1110
1211class BindsLdapUserModel
1312{
1413 /**
1514 * Binds the LDAP user record to their model.
1615 *
17- * @param Authenticated $event
16+ * @param mixed $event
1817 *
1918 * @return void
2019 */
21- public function handle (Authenticated $ event )
20+ public function handle ($ event )
2221 {
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+ ) {
2430 $ event ->user ->setLdapUser (
2531 Resolver::byModel ($ event ->user )
2632 );
You can’t perform that action at this time.
0 commit comments