'How to check status login and redirect to dashboard in Redux
I created two pages: <login> and <dashboard>. In login form I create userInput and passwordInput and button submit. When the user type and click into button submit. When app start ,how to check if user logined to app, it will redirect to <dashboard> and if user have not login to app, it will redirect to login? Thanks you for support
Solution 1:[1]
Check with your token in cookies or local storage with the following database users
export default function route(){
if a user exists in your DB then set validation true or either false
let validation=localStorage.getItem("token");
if(validation){
return(<Dashboard/>)
}
else{
return(<Login/>)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | tirth1620 |
