0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-22 23:59:42 +00:00

Added files missed in previous commit

This commit is contained in:
Dan Brown 2020-02-02 10:59:03 +00:00
parent 3470a6a140
commit e743cd3f60
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
21 changed files with 139 additions and 229 deletions

View file

@ -65,7 +65,6 @@ class LoginController extends Controller
{
$socialDrivers = $this->socialAuthService->getActiveDrivers();
$authMethod = config('auth.method');
$samlEnabled = config('saml2.enabled') === true;
if ($request->has('email')) {
session()->flashInput([
@ -77,7 +76,6 @@ class LoginController extends Controller
return view('auth.login', [
'socialDrivers' => $socialDrivers,
'authMethod' => $authMethod,
'samlEnabled' => $samlEnabled,
]);
}
@ -129,28 +127,16 @@ class LoginController extends Controller
*/
protected function validateLogin(Request $request)
{
$rules = [];
$rules = ['password' => 'required|string'];
$authMethod = config('auth.method');
if ($authMethod === 'standard') {
$rules = [
'email' => 'required|string|email',
'password' => 'required|string'
];
$rules['email'] = 'required|email';
}
if ($authMethod === 'ldap') {
$rules = [
'username' => 'required|string',
'password' => 'required|string',
'email' => 'email',
];
}
if ($authMethod === 'saml2') {
$rules = [
'email' => 'email',
];
$rules['username'] = 'required|string';
$rules['email'] = 'email';
}
$request->validate($rules);
@ -178,10 +164,6 @@ class LoginController extends Controller
*/
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();

View file

@ -75,10 +75,8 @@ class RegisterController extends Controller
{
$this->registrationService->checkRegistrationAllowed();
$socialDrivers = $this->socialAuthService->getActiveDrivers();
$samlEnabled = (config('saml2.enabled') === true) && (config('saml2.auto_register') === true);
return view('auth.register', [
'socialDrivers' => $socialDrivers,
'samlEnabled' => $samlEnabled,
]);
}

View file

@ -20,7 +20,8 @@ class Saml2Controller extends Controller
// SAML2 access middleware
$this->middleware(function ($request, $next) {
if (!config('saml2.enabled')) {
if (config('auth.method') !== 'saml2') {
$this->showPermissionError();
}