2
2
3
3
namespace Adldap \Laravel ;
4
4
5
+ use Illuminate \Contracts \Hashing \Hasher ;
5
6
use Illuminate \Support \Facades \Auth ;
6
7
use Illuminate \Support \ServiceProvider ;
7
8
@@ -30,19 +31,19 @@ public function boot()
30
31
31
32
$ this ->mergeConfigFrom ($ auth , 'adldap_auth ' );
32
33
33
- $ auth = Auth:: getFacadeRoot ();
34
+ $ auth = $ this -> getAuth ();
34
35
35
36
if (method_exists ($ auth , 'provider ' )) {
36
37
// If the provider method exists, we're running Laravel 5.2.
37
38
// Register the adldap auth user provider.
38
39
$ auth ->provider ('adldap ' , function ($ app , array $ config ) {
39
- return new AdldapAuthUserProvider ($ app ['hash ' ], $ config ['model ' ]);
40
+ return $ this -> newAdldapAuthUserProvider ($ app ['hash ' ], $ config ['model ' ]);
40
41
});
41
42
} else {
42
43
// Otherwise we're using 5.0 || 5.1
43
44
// Extend Laravel authentication with Adldap driver.
44
45
$ 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 ' ]);
46
47
});
47
48
}
48
49
}
@@ -66,4 +67,27 @@ public function provides()
66
67
{
67
68
return ['auth ' ];
68
69
}
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
+ }
69
93
}
0 commit comments