Commit 06760006 by zhanghaozhe

cookie失效跳转登录

parent f8861e99
...@@ -26,7 +26,14 @@ class App extends Component { ...@@ -26,7 +26,14 @@ class App extends Component {
cookie.set('plat', '5') cookie.set('plat', '5')
http.get(`${api.home}/m/user_info`).then(res => { http.get(`${api.home}/m/user_info`).then(res => {
this.props.setCurrentUser(this.storeUser(res)) if (res.data.code === 4040) {
if (!location.pathname.includes('/passport')) {
location.assign('/passport')
}
} else {
this.props.setCurrentUser(this.storeUser(res))
}
}) })
} }
...@@ -38,7 +45,8 @@ class App extends Component { ...@@ -38,7 +45,8 @@ class App extends Component {
avatar_file: avatar, avatar_file: avatar,
user_name: username, user_name: username,
is_vip: isVIP, is_vip: isVIP,
uid uid,
code
} }
} = res.data } = res.data
...@@ -49,13 +57,15 @@ class App extends Component { ...@@ -49,13 +57,15 @@ class App extends Component {
username, username,
isVIP, isVIP,
avatar, avatar,
uid uid,
code
} }
} }
} else { } else {
payload = { payload = {
hasError: true, hasError: true,
msg: res.data.msg msg: res.data.msg,
code: res.data.code
} }
} }
return payload return payload
......
import React, { Component } from 'react' import React, { Component } from 'react'
import { Route, Switch } from 'react-router-dom' import { Route, Switch, Redirect } from 'react-router-dom'
import './passport.scss' import './passport.scss'
import {WithFullSize} from '@/HOCs' import { WithFullSize } from '@/HOCs'
import WechatLogin from './wechatLogin' import WechatLogin from './wechatLogin'
import AccountLogin from './accountLogin' import AccountLogin from './accountLogin'
import ForgotPassword from './forgotPassword' import ForgotPassword from './forgotPassword'
...@@ -42,10 +42,15 @@ class Passport extends Component { ...@@ -42,10 +42,15 @@ class Passport extends Component {
} }
render() { render() {
let {match} = this.props let {match, location} = this.props
console.log(location)
return ( return (
<div className="passport"> <div className="passport">
<Switch> <Switch>
<Redirect exact
from={'/passport'}
to={{...location, ...{pathname: '/passport/account-login'}}}
/>
<Route path={match.url + '/wechat-login'} <Route path={match.url + '/wechat-login'}
render={() => <WechatLogin loginWays={this.state.loginWays}/>}/> render={() => <WechatLogin loginWays={this.state.loginWays}/>}/>
<Route path={match.url + '/account-login'} component={AccountLogin}/> <Route path={match.url + '/account-login'} component={AccountLogin}/>
......
...@@ -11,7 +11,7 @@ const PrivateRoute = ({component: Component, path, user, ...rest}) => { ...@@ -11,7 +11,7 @@ const PrivateRoute = ({component: Component, path, user, ...rest}) => {
return authenticated return authenticated
? <Component {...props}/> ? <Component {...props}/>
: <Redirect to={{ : <Redirect to={{
pathname: '/passport/account-login', pathname: '/passport',
state: {from: props.location} 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