laravel / nova-issues

554 stars 35 forks source link

Intended url redirect not working #4615

Closed henryavila closed 2 years ago

henryavila commented 2 years ago

Description:

If I access any url that requires the user to be authenticated, without been authenticated on Nova, I will be redirect to login page, and after that, Nova will load the main Dashboard, but the correct is redirect back to intended url

Detailed steps to reproduce the issue on a fresh Nova installation:

crynobone commented 2 years ago

That's the expected behaviour to any Laravel login. Rebind the LoginController if you want something differently.

henryavila commented 2 years ago

@crynobone sorry, but I believe you are wrong.

Redirect to intended url is de default behavior, and it's implemented on Nova, and works fine on Nova v3.

See this code from Nova

namespace Laravel\Nova\Http\Controllers;

class LoginController extends Controller
{
   /**
     * The user has been authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  mixed  $user
     * @return mixed
     */
    protected function authenticated(Request $request, $user)
    {
        $redirect = redirect()->intended($this->redirectPath());

        return $request->wantsJson()
            ? new JsonResponse([
                'redirect' => $redirect->getTargetUrl(),
            ], 200)
            : $redirect;
    }
}

The intended redirect is implemented on Nova, it was working on Nova 3, but for some reason, it's not working on Nova 4

ArtDepartmentMJ commented 2 years ago

I'm experiencing the same issue, is there any update on this?