Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit cd4adce

Browse files
committed
Added Laravel 5.1 and lower compatibility for new version
1 parent 429c708 commit cd4adce

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/AdldapAuthServiceProvider.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,21 @@ public function boot()
3030

3131
$this->mergeConfigFrom($auth, 'adldap_auth');
3232

33-
// Register the adldap auth user provider.
34-
Auth::provider('adldap', function ($app, array $config) {
35-
return new AdldapAuthUserProvider($app['hash'], $config['model']);
36-
});
33+
$auth = Auth::getFacadeRoot();
34+
35+
if (method_exists($auth, 'provider')) {
36+
// If the provider method exists, we're running Laravel 5.2.
37+
// Register the adldap auth user provider.
38+
$auth->provider('adldap', function ($app, array $config) {
39+
return new AdldapAuthUserProvider($app['hash'], $config['model']);
40+
});
41+
} else {
42+
// Otherwise we're using 5.0 || 5.1
43+
// Extend Laravel authentication with Adldap driver.
44+
$auth->extend('adldap', function ($app) {
45+
return new AdldapAuthUserProvider($app['hash'], $app['config']['auth.model']);
46+
});
47+
}
3748
}
3849

3950
/**

0 commit comments

Comments
 (0)