Commit a90316df by zhanghaozhe

cookie失效处理

parent 06760006
......@@ -26,14 +26,7 @@ class App extends Component {
cookie.set('plat', '5')
http.get(`${api.home}/m/user_info`).then(res => {
if (res.data.code === 4040) {
if (!location.pathname.includes('/passport')) {
location.assign('/passport')
}
} else {
this.props.setCurrentUser(this.storeUser(res))
}
this.props.setCurrentUser(this.storeUser(res))
})
}
......
......@@ -15,7 +15,12 @@ import PasswordInput from '../common/passwordInput'
// import LoginWays from '../common/LoginWays'
class AccountLogin extends PureComponent {
componentDidMount(){
console.log(this.props.location)
}
render() {
return (
<div className={'account-login'}>
......
import React from 'react';
import { connect } from 'react-redux';
import { withRouter } from "react-router-dom";
import { compose } from "redux";
const Loading = ({user, history, state}) => {
if (Object.values(user.data).filter(item => !!item).length !== 0) {
history.replace(location.pathname)
} else {
history.replace('/passport', {...state})
}
return (
<div className={'loading'}>
loading...
</div>
);
};
export default compose(
connect(
state => ({user: state.user}),
null
),
withRouter
)(Loading);
\ No newline at end of file
......@@ -2,6 +2,7 @@ import React from 'react';
import { Route, Redirect } from "react-router-dom";
import { connect } from "react-redux";
import jsCookie from 'js-cookie'
import Loading from './loading'
const PrivateRoute = ({component: Component, path, user, ...rest}) => {
......@@ -10,10 +11,7 @@ const PrivateRoute = ({component: Component, path, user, ...rest}) => {
<Route {...rest} render={props => {
return authenticated
? <Component {...props}/>
: <Redirect to={{
pathname: '/passport',
state: {from: props.location}
}}/>
: <Loading state={{from: props.location}}/>
}}/>
);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment