Laravel redirect when session expires and user does a POST request
Hello. In my Laravel application I have the default Authentication, and when an user is not logged in, but he tries to access an URL, he is redirected to login, then if he logins successfully, he is again redirected to the URL he initially tried to access. Everything works fine, unless the URL he actually tried to access is a POST. For example if the user is on a page where he wants to edit something, and he stays there for more than a few hours(more than whatever the sessions expiry time is) and then he presses save, the browser will send the data via a POST request, and then Laravel will redirect the user to the login page, and after the user successfully logs in redirect him to the same page, but with GET instead of POST. If that route exists, all fine, he lost some data, but he doesn't see an error. But if the GET route doesn't exists, he will see an error. Is there a way to not redirect the user if the request was not a GET after login ? I'm using public function redirectTo() { return redirect()->back(); } in the login controller to send the user back to last page.
Please or to participate in this conversation.