mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
(Maybe?) Fixes the problem where we always need LDAP enabled (#9321)
* I *think* this fixes the problem where we need LDAP even if we aren't using it? * Pull the LdapAd dependency out of the AuthController constructor
This commit is contained in:
parent
cacb707a7f
commit
2a28f5e66c
|
@ -58,12 +58,12 @@ class LoginController extends Controller
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(LdapAd $ldap, Saml $saml)
|
||||
public function __construct(/*LdapAd $ldap, */ Saml $saml)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->middleware('guest', ['except' => ['logout','postTwoFactorAuth','getTwoFactorAuth','getTwoFactorEnroll']]);
|
||||
Session::put('backUrl', \URL::previous());
|
||||
$this->ldap = $ldap;
|
||||
// $this->ldap = $ldap;
|
||||
$this->saml = $saml;
|
||||
}
|
||||
|
||||
|
@ -140,10 +140,10 @@ class LoginController extends Controller
|
|||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function loginViaLdap(Request $request): User
|
||||
private function loginViaLdap(LdapAd $ldap, Request $request): User
|
||||
{
|
||||
try {
|
||||
return $this->ldap->ldapLogin($request->input('username'), $request->input('password'));
|
||||
return $ldap->ldapLogin($request->input('username'), $request->input('password'));
|
||||
} catch (\Exception $ex) {
|
||||
LOG::debug("LDAP user login: " . $ex->getMessage());
|
||||
throw new \Exception($ex->getMessage());
|
||||
|
@ -217,7 +217,7 @@ class LoginController extends Controller
|
|||
$user = null;
|
||||
|
||||
// Should we even check for LDAP users?
|
||||
if ($this->ldap->init()) {
|
||||
if (Setting::getSettings()->ldap_enabled) { // avoid hitting the $this->ldap
|
||||
LOG::debug("LDAP is enabled.");
|
||||
try {
|
||||
LOG::debug("Attempting to log user in by LDAP authentication.");
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
use App\Services\LdapAd;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Contracts\Support\DeferrableProvider;
|
||||
|
||||
class LdapServiceProvider extends ServiceProvider
|
||||
class LdapServiceProvider extends ServiceProvider implements DeferrableProvider
|
||||
{
|
||||
|
||||
/**
|
||||
|
@ -26,4 +27,14 @@ class LdapServiceProvider extends ServiceProvider
|
|||
{
|
||||
$this->app->singleton(LdapAd::class, LdapAd::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [LdapAd::class];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue