Laravel 認証には dsdevbe/ldap-connector を使用します。この目的のために、デフォルトの AuthController を使用し、AuthenticateAndRegistersUsers から postLogin メソッドを追加して、次の変更を加えました。
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.',
]);
}
間違った$this->auth->attempt()
資格情報を使用すると、エラーが発生して認証/ログインにリダイレクトされます。正しい資格情報を使用すると、/dashboard にリダイレクトされますが、auth/login にリダイレクトされるため、セッションが正しく機能していないようです。dd($this->auth->check());
出力しようとすると、ダッシュボードへのリダイレクトのtrue
前と後になります。false
誰でも問題を知っていて、それを助けることができますか?
セッションはうまく機能し、ブレード テンプレートsession(['test' => true]);
の下attempt()
と下でテストされています。@if(session('test')) {{ "works" }} @endif
auth/login
ありがとう。