-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inertia - Expired session causes the website to be displayed in a modal #128
Comments
Is your Jetstream/Laravel environment set to Dev or Production? -- https://inertiajs.com/error-handling |
It seems to me that doesn't matter, because that's meant for error pages.
However, this behaviour is not typical error behaviour to me. I expect the user to be redirected to the login page, not a modal that shows the login page |
Related inertiajs/inertia-laravel#57 (and potential solution inertiajs/inertia-laravel#57 (comment)). Perhaps something that wouldn't be too difficult to take care of by overwriting This worked for me: protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->inertia()) {
return response('', 409)->header('X-Inertia-Location', $exception->redirectTo() ?? route('login'));
}
return parent::unauthenticated($request, $exception);
} |
Also having this issue, opening in a modal. |
@reinink do you might know what exactly needs to be done for this? The solution from above maybe? I didn't immediately found anything in the Inertia docs but I'm also very new to Inertia so not sure if I was looking in the right places. |
@driesvints Happy to look into this for you. Give me a couple days. I'm actually hoping to also submit a PR to Jetstream for some recent updates to Inertia.js as well. I'll be in touch. 👍 |
@reinink awesome. Thanks! |
Maybe a hard redirect to the login with intended redirect after would fix @reinink? 🤔 |
Yes, we could do an @claudiodekker has already done this work, which you can find here: #298. However, I can see that it has been tagged for the 2.x release. I don't really see how this is a breaking change though (correct me if I'm wrong @driesvints), so I actually think it would be better to just merge this into 1.x. |
Best to check with @taylorotwell. I do think it's a breaking change because it's simply not how the auth layer works in the current stable release. People might be caught off guard when this part of the stack changes. |
Understood buddy! Maybe I'm just misunderstanding. My understanding is that once Jetstream is installed, all the views are published to your |
The way I understand that PR is that it's required to publish the new vue views to your resources directory and included them in your auth scaffold. Maybe I'm misunderstanding 🤔 |
Yeah, you're right. You would have to publish the views again, and in that sense it doesn't fix the issue for the existing users. Okay, let me try put a fix together for this using |
I have the same issue: https://ibb.co/68b7Jf9 |
I think this issue can be closed now, as this will be fixed in the 2.x release of Jetstream since #298 is now merged into master. This issue is caused by the the auth pages which currently return a blade view. In 2.x all of Jetstreams auth pages will be Inertia responses. When a middleware then redirects to the login page it should render correctly. |
My workaround is to use
|
I know this is closed but I've finally pushed my project into production and this became an issue where it wasn't in development. Here's what I did to fix it. I placed this code in the Authenticate.php middleware and removed the default and it worked perfectly:
I haven't upgraded inertia yet and don't plan on it until things become more stable with the entire laravel/jetstream/inertia stack so this works for now. Hope it helps someone! |
Thank you so much! Worked perfect on me also! |
also as the documentation said you should add custom error pages and add some code in Exeptions/Handler to avoid this misbehavior (not exactly cause this feature meant to show to the developer ) |
This didn't work for me because it seemed like the /**
* Prepare exception for rendering.
*
* @param $request
* @param \Throwable $e
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
* @throws Throwable
*/
public function render($request, Throwable $e)
{
$response = parent::render($request, $e);
if ($response->status() === 419) {
$location = $e instanceof AuthenticationException ? $e->redirectTo() : route('login');
return response('', 409)->header('X-Inertia-Location', $location);
}
return $response;
} |
Description:
When the session expires the user doesn't get redirected to the login page, but instead this page is shown as a modal. After logging in within the modal the website is shown inside the modal.
Steps To Reproduce:
laravel new saas --jet --stack=inertia --teams
laravel_session
cookieThe text was updated successfully, but these errors were encountered: