Commit 06760006 by zhanghaozhe

cookie失效跳转登录

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