use BookStack\Auth\Access\SocialAuthService;
use BookStack\Exceptions\LoginAttemptEmailNeededException;
use BookStack\Exceptions\LoginAttemptException;
+use BookStack\Exceptions\UserRegistrationException;
use BookStack\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
*/
public function __construct(SocialAuthService $socialAuthService)
{
- $this->middleware('guest', ['only' => ['getLogin', 'postLogin']]);
+ $this->middleware('guest', ['only' => ['getLogin', 'login']]);
+ $this->middleware('guard:standard,ldap', ['only' => ['login', 'logout']]);
+
$this->socialAuthService = $socialAuthService;
$this->redirectPath = url('/');
$this->redirectAfterLogout = url('/login');
]);
}
+ $previous = url()->previous('');
+ if (setting('app-public') && $previous && $previous !== url('/login')) {
+ redirect()->setIntendedUrl($previous);
+ }
+
return view('auth.login', [
'socialDrivers' => $socialDrivers,
'authMethod' => $authMethod,
return $this->sendFailedLoginResponse($request);
}
+ /**
+ * The user has been authenticated.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param mixed $user
+ * @return mixed
+ */
+ protected function authenticated(Request $request, $user)
+ {
+ // Authenticate on all session guards if a likely admin
+ if ($user->can('users-manage') && $user->can('user-roles-manage')) {
+ $guards = ['standard', 'ldap', 'saml2'];
+ foreach ($guards as $guard) {
+ auth($guard)->login($user);
+ }
+ }
+
+ return redirect()->intended($this->redirectPath());
+ }
+
/**
* Validate the user login request.
*
return redirect('/login');
}
- /**
- * Log the user out of the application.
- */
- public function logout(Request $request)
- {
- $this->guard()->logout();
- $request->session()->invalidate();
-
- return $this->loggedOut($request) ?: redirect('/');
- }
}