jeudi 28 mars 2019

Laravel login - Fail condition isn't working

I'm creating a login api in Laravel.

I have a login method

public function authenticate(Request $request)
    {
        $credentials = $request->only('email', 'password');

        if (Auth::attempt($credentials)) {
            return response()->json(auth()->user());
        } else {

        }

        return Response::json(['message' => 'Failed to authenticate'], 401);
    }

If the login fails it doesn't reach the 401 error. Any reason why?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire