Redirect user to previous page after login


I want to redirect back user after logged in to the route that previously my auth middleware disallowed user and redirected him/her to the login page , Laravel has intended() function to handle this .
how should I implement this process ? also my login is 2-step verification.

Hi @iamintaheri!

I am not aware of any built in methods for it, but I have idea how to implement it by yourself quite easily.

When user tries to access page that has behind login wall, then right before redirecting to /login add GET param (or cookie) with target URL. Login URL would look something like this: /login?target=dashboard. With two step verification cookie might be little bit easier since you don’t have to pass param over multiple routes

Then finally when login is success you can read this GET param / cookie for target URL and redirect and remove cookie (or just ignore it).