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實際上登入和註冊過程。 –
登錄後,但在推入下一個狀態之前 –