简体   繁体   English

在聚合物注销后如何防止用户返回上一页

[英]How to prevent user from going back to previous page after logout in polymer

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. 现在,如果用户单击浏览器后退按钮,他将被带到上一个网址。如何防止这种情况发生。

There is no proper way to change the history object of window . 没有适当的方法来更改windowhistory对象。 But, here are some crazy ideas you can try: 但是,您可以尝试以下一些疯狂的想法:

  • You can overwrite history.back() and make it null if user is logged out. 您可以覆盖history.back()并在用户注销后使其为null。
  • 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. 您可以在每次页面更改时检查用户是否登录,如果没有登录,则可以使用location.replace("you 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). 注销后,您可以从铁页中删除除主页以外的所有子元素,然后在用户登录(或刷新页面)时再次添加它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试防止用户退出后无法返回上一页 - Trying to prevent user from going back to previous page after logout is not working 在ASP.NET中注销后如何阻止/阻止用户返回上一页 - How to block / prevent user to go back to previous page after logout in ASP.NET 无法阻止用户返回上一个“登录”页面 - Unable to prevent user from going back to previous Log In page 如何防止用户返回 ASP.NET 中的上一页 - How to prevent user from going back to previous page in ASP.NET 如何防止用户在页面上后退/前进? - How to prevent a user from going back/forward when they are on a page? 防止返回按钮返回上一页以获得ID - Prevent back button from going back to previous page for an ID 禁止用户在注销后返回安全页面,jsp 和 firefox 5.0 - prohibit the user from going back to a secure page after logout,jsp with firefox 5.0 防止转到浏览器后退按钮上的上一页 - Prevent going to the previous page on browser back button 在angular2中注销后,如何通过浏览器后退按钮禁止用户访问上一页? - How to disable users from accessing previous page by browser back button after logout in angular2? 在angularjs应用程序中注销后,如何通过浏览器后退按钮禁止用户访问上一页? - How to disable users from accessing previous page by browser back button after logout in angularjs application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM