use BookStack\Exceptions\AuthException;
use BookStack\Http\Controllers\Controller;
use BookStack\Repos\UserRepo;
-use BookStack\Repos\LdapRepo;
+use BookStack\Services\LdapService;
use BookStack\Services\SocialAuthService;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
protected $redirectAfterLogout = '/login';
protected $socialAuthService;
+ protected $ldapService;
protected $userRepo;
/**
* Create a new controller instance.
*
* @param SocialAuthService $socialAuthService
+ * @param LdapService $ldapService
* @param UserRepo $userRepo
*/
- public function __construct(SocialAuthService $socialAuthService, UserRepo $userRepo)
+ public function __construct(SocialAuthService $socialAuthService, LdapService $ldapService, UserRepo $userRepo)
{
$this->middleware('guest', ['only' => ['getLogin', 'postLogin']]);
$this->socialAuthService = $socialAuthService;
+ $this->ldapService = $ldapService;
$this->userRepo = $userRepo;
$this->redirectPath = baseUrl('/');
$this->redirectAfterLogout = baseUrl('/login');
auth()->login($user);
}
- // ldap groups refresh
- if (config('services.ldap.user_to_groups') !== false && $request->filled('username')) {
- $ldapRepo = new LdapRepo($this->userRepo);
- $ldapRepo->syncGroups($user,$request->input('username'));
- }
-
+ // Sync LDAP groups if required
+ if ($this->ldapService->shouldSyncGroups()) {
+ $this->ldapService->syncGroups($user);
+ }
- $path = session()->pull('url.intended', '/');
+ $path = session()->pull('url.intended', '/');
$path = baseUrl($path, true);
return redirect($path);
}
* Redirect to the relevant social site.
* @param $socialDriver
* @return \Symfony\Component\HttpFoundation\RedirectResponse
+ * @throws \BookStack\Exceptions\SocialDriverNotConfigured
*/
public function getSocialLogin($socialDriver)
{