[英]How to prevent user from seeing login page after logged in?
I'm working on a react app, the issue is that after logging in and click on back button inside browser I can see the login page,我正在开发一个反应应用程序,问题是登录并单击浏览器内的后退按钮后,我可以看到登录页面,
What should be the best approach to prevent this?防止这种情况的最佳方法应该是什么?
Can you guide me a little bit??你能指导我一点吗??
If you are using react-router you can use redirect in your login component如果您使用 react-router 您可以在登录组件中使用重定向
if (userIsLogged) {
return <Redirect to={"/homepage"} />;
}
You can use Route Gurad Module您可以使用 Route Gurad 模块
https://www.npmjs.com/package/react-router-guards or refer to this example as well. https://www.npmjs.com/package/react-router-guards或参考这个例子。
How to restrict access to routes in react-router? 如何限制对 react-router 中路由的访问?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.