namespace BookStack\Http\Controllers\Auth;
+use BookStack\Auth\Access\LdapService;
+use BookStack\Auth\Access\SocialAuthService;
+use BookStack\Auth\UserRepo;
use BookStack\Exceptions\AuthException;
use BookStack\Http\Controllers\Controller;
-use BookStack\Repos\UserRepo;
-use BookStack\Services\LdapService;
-use BookStack\Services\SocialAuthService;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
/**
* Create a new controller instance.
*
- * @param SocialAuthService $socialAuthService
+ * @param \BookStack\Auth\\BookStack\Auth\Access\SocialAuthService $socialAuthService
* @param LdapService $ldapService
- * @param UserRepo $userRepo
+ * @param \BookStack\Auth\UserRepo $userRepo
*/
public function __construct(SocialAuthService $socialAuthService, LdapService $ldapService, UserRepo $userRepo)
{
$this->socialAuthService = $socialAuthService;
$this->ldapService = $ldapService;
$this->userRepo = $userRepo;
- $this->redirectPath = baseUrl('/');
- $this->redirectAfterLogout = baseUrl('/login');
+ $this->redirectPath = url('/');
+ $this->redirectAfterLogout = url('/login');
parent::__construct();
}
$user->save();
$this->userRepo->attachDefaultRole($user);
+ $this->userRepo->downloadAndAssignUserAvatar($user);
auth()->login($user);
}
$this->ldapService->syncGroups($user, $request->get($this->username()));
}
- $path = session()->pull('url.intended', '/');
- $path = baseUrl($path, true);
- return redirect($path);
+ return redirect()->intended('/');
}
/**
{
$socialDrivers = $this->socialAuthService->getActiveDrivers();
$authMethod = config('auth.method');
+ $samlEnabled = config('saml2.enabled') === true;
if ($request->has('email')) {
session()->flashInput([
]);
}
- return view('auth/login', ['socialDrivers' => $socialDrivers, 'authMethod' => $authMethod]);
+ return view('auth.login', [
+ 'socialDrivers' => $socialDrivers,
+ 'authMethod' => $authMethod,
+ 'samlEnabled' => $samlEnabled,
+ ]);
}
/**
session()->put('social-callback', 'login');
return $this->socialAuthService->startLogIn($socialDriver);
}
+
+ /**
+ * Log the user out of the application.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return \Illuminate\Http\Response
+ */
+ public function logout(Request $request)
+ {
+ if (config('saml2.enabled') && session()->get('last_login_type') === 'saml2') {
+ return redirect('/saml2/logout');
+ }
+
+ $this->guard()->logout();
+
+ $request->session()->invalidate();
+
+ return $this->loggedOut($request) ?: redirect('/');
+ }
}