skip to Main Content

I’ve got a route and a bit of code to login as another user, but when you click the link, you are logged in as the new user, but if I press back in the browser it goes back to a restricted link and errors as the user doesn’t have access. How can I log in the user and basically disable the back button? Previously I have use javascript to open a new tab and close the old one, this works, but sometimes there is a weird timing issue where the original tab doesn’t close.

2

Answers


  1. In the link handler, probably in controller you check, if the current user is logged in as another user, you get request back by:

    return redirect()->back()
    

    Else (meaning nobody is logged in and need to show an error) – show an error

    Login or Signup to reply.
  2. Read authentication, authorization and middleware from laravel documentation.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search