0

I am working on polymer app where the landing page itself is the sign-in page and after the user logs out successfully i am redirecting him to sign-in page like this

   window.history.pushState({}, null, '/');
   window.dispatchEvent(new CustomEvent('location-changed'));

now if the user clicks browser back button he will be taken to previous Url.How do I prevent this from happening.

aries12
  • 370
  • 2
  • 18

1 Answers1

0

There is no proper way to change the history object of window. But, here are some crazy ideas you can try:

  • You can overwrite history.back() and make it null if user is logged out.
  • You can have a check each time a page changes for if user is logged in, if not then you can use location.replace("you home page") to take him back to home page.
  • After logout you can remove all the child elements from iron-pages except for your home page and then add them again when user logs in(or refresh the page).
a1626
  • 2,953
  • 1
  • 19
  • 34