0
用户成功注册后退按钮后不应让用户注册,除非用户从配置文件注销。用户登录成功后不要重定向后退按钮
这里的代码:
function checkAuth(nextState) {
let loginUserData = window.localStorage.getItem("user")
loginUserData = loginUserData ? JSON.parse(loginUserData) : null
if (loginUserData !== null && loginUserData.userType === 'client') {
if(nextState.location.pathname === `${INDEX_ROUTE}/*`){
browserHistory.push('/')
}else{
console.log('not found')
}
} else if(loginUserData !== null && loginUserData.userType === 'freelancer' && window.localStorage.getItem('step3') === undefined) {
if(nextState.location.pathname ==='/dashboard/payment'){
browserHistory.push('/')
}else{
browserHistory.push('/dashboard')
}
}
}
ReactDOM.render(
<MuiThemeProvider muiTheme={muiTheme}>
<Provider store={store}>
<Router history={history} >
<Route path="/" component={Layout}>
<Route path="/thankyou" onEnter={checkAuth} component={Thankyou}
/>
</Router>
</Provider>
</MuiThemeProvider>,
document.getElementById('root')
)
如何在路线的路线checkauth功能使用browserHistory实际上登入和注册过程。 –
登录后,但在推入下一个状态之前 –