Fortify laravel 10 - login issue on production

66 Views Asked by At

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.

1

There are 1 best solutions below

0
mohamad zbib On BEST ANSWER

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.