How to get more information from Auth::attempt false return?

Viewed 60

A similar question found but remains unanswered.

I'm using LDAP service for the authentication and wondering how can I get useful information from Auth::attempt because it always return false. A similar LDAP implementation works fine for my other applications.

Is there a method I can call from Auth to retrieve any error messages?

    public function authenticate(Request $request)
    {
        $this->validate($request, [
            'name' => 'required',
            'password' => 'required',
        ]);
        $name = $request->input('name');
        $password = $request->input('password');
        $reg = $request->input('domain');

        if (Auth::attempt([ 'name' => $name, 'password' => $password, 'domain' => $reg ])) {
            $request->session()->put('Username', $name);
            return redirect()->intended('/adminpage');
        } else {
            // this is always triggered because Auth::attempt is false
            return redirect()->back()->withInput()->withErrors('LDAP authentication failed');
        }
    }
0 Answers
Related