laravellaravel-jetstream

Fortify laravel 10 - login issue on production


I am using Laravel 10 with jetstream +livewire.

in my local host everything is fine, but on server I have an issue.

when I login with wrong credential it redirect me to home page without error and without login.

I tried to to clear cache, update composer, not working.


Solution

  • The issue is that the validation error is thrown, to home page. and i have fixed it by adding this code to FortifyServiceProvider

        Fortify::authenticateUsing(function (Request $request) {
            $user = User::where('email', $request->email)->first();
    
            if ($user && Hash::check($request->password, $user->password)) {
                return $user;
            }
    
            throw ValidationException::withMessages([
                'email' => [trans('auth.failed')],
            ])->redirectTo('login');
        });
    

    by adding redirectTo('login') to the ValidationException solves the problem.