This repository was archived by the owner on Jul 24, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +13
-6
lines changed
Expand file tree Collapse file tree 4 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 33<p align =" center " >
44 <a href="www.laravel.com"><img src="https://img.shields.io/badge/Built_for-Laravel-green.svg?style=flat-square"></a>
55 <a href="https://travis-ci.org/Adldap2/Adldap2-Laravel"><img src="https://img.shields.io/travis/Adldap2/Adldap2-Laravel.svg?style=flat-square"></a>
6- <a href="https://travis-ci.org/Adldap2/Adldap2-Laravel"><img src="https://img.shields.io/travis/Adldap2/Adldap2-Laravel.svg?style=flat-square"></a>
76 <a href="https://scrutinizer-ci.com/g/Adldap2/Adldap2-Laravel"><img src="https://img.shields.io/scrutinizer/g/Adldap2/Adldap2-laravel/master.svg?style=flat-square"></a>
87 <a href="https://packagist.org/packages/adldap2/adldap2-laravel"><img src="https://img.shields.io/packagist/dt/adldap2/adldap2-laravel.svg?style=flat-square"></a>
98 <a href="https://packagist.org/packages/adldap2/adldap2-laravel"><img src="https://img.shields.io/packagist/v/adldap2/adldap2-laravel.svg?style=flat-square"></a>
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 );
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ public function auth_attempts_fallback_using_config_option()
133133 ];
134134
135135 Resolver::shouldReceive ('byCredentials ' )->times (3 )->andReturn (null )
136- ->shouldReceive ('byModel ' )->once ( )->andReturn (null );
136+ ->shouldReceive ('byModel ' )->times ( 2 )->andReturn (null );
137137
138138 $ this ->assertTrue (Auth::attempt ($ credentials ));
139139
You can’t perform that action at this time.
0 commit comments