I use dsdevbe/ldap-connector for Laravel authentication. For this purpose I used the default AuthController and added the postLogin method from AuthenticatesAndRegistersUsers with following changes:
public function postLogin(Request $request)
{
$this->validate($request, [
'username' => 'required',
'password' => 'required',
]);
$credentials = $request->only('username', 'password');
if ($this->auth->attempt($credentials))
{
return redirect()->intended('/dashboard');
}
return redirect($this->loginPath())
->withInput($request->only('username'))
->withErrors([
'username' => 'Benutzername oder Passwort falsch.',
]);
}
The $this->auth->attempt()
works fine, when I use incorrect credentials I'm getting redirected to auth/login with an error. When I use correct credentials I'm getting redirected to /dashboard, but the sessions doesn't seem to work properly, because I get a reredirect to auth/login. When I try to dd($this->auth->check());
the output is true
before, and false
after the redirect to dashboard.
Anybody know the issue and can help with that?
Sessions works well, tested with session(['test' => true]);
under attempt()
and with @if(session('test')) {{ "works" }} @endif
in auth/login
blade template.
Thanks.