22
33namespace Adldap \Laravel ;
44
5+ use Illuminate \Contracts \Hashing \Hasher ;
56use Illuminate \Support \Facades \Auth ;
67use Illuminate \Support \ServiceProvider ;
78
@@ -30,19 +31,19 @@ public function boot()
3031
3132 $ this ->mergeConfigFrom ($ auth , 'adldap_auth ' );
3233
33- $ auth = Auth:: getFacadeRoot ();
34+ $ auth = $ this -> getAuth ();
3435
3536 if (method_exists ($ auth , 'provider ' )) {
3637 // If the provider method exists, we're running Laravel 5.2.
3738 // Register the adldap auth user provider.
3839 $ auth ->provider ('adldap ' , function ($ app , array $ config ) {
39- return new AdldapAuthUserProvider ($ app ['hash ' ], $ config ['model ' ]);
40+ return $ this -> newAdldapAuthUserProvider ($ app ['hash ' ], $ config ['model ' ]);
4041 });
4142 } else {
4243 // Otherwise we're using 5.0 || 5.1
4344 // Extend Laravel authentication with Adldap driver.
4445 $ auth ->extend ('adldap ' , function ($ app ) {
45- return new AdldapAuthUserProvider ($ app ['hash ' ], $ app ['config ' ]['auth.model ' ]);
46+ return $ this -> newAdldapAuthUserProvider ($ app ['hash ' ], $ app ['config ' ]['auth.model ' ]);
4647 });
4748 }
4849 }
@@ -66,4 +67,27 @@ public function provides()
6667 {
6768 return ['auth ' ];
6869 }
70+
71+ /**
72+ * Returns a new instance of the AdldapAuthUserProvider.
73+ *
74+ * @param Hasher $hasher
75+ * @param string $model
76+ *
77+ * @return AdldapAuthUserProvider
78+ */
79+ protected function newAdldapAuthUserProvider (Hasher $ hasher , $ model )
80+ {
81+ return new AdldapAuthUserProvider ($ hasher , $ model );
82+ }
83+
84+ /**
85+ * Returns the root Auth instance.
86+ *
87+ * @return mixed
88+ */
89+ protected function getAuth ()
90+ {
91+ return Auth::getFacadeRoot ();
92+ }
6993}
0 commit comments