Commit bd76f496 by FE

login redirect modify

parent 7b67b3fb
...@@ -74,14 +74,15 @@ const formikConfig = { ...@@ -74,14 +74,15 @@ const formikConfig = {
const {props, props: {history}} = formikBag const {props, props: {history}} = formikBag
props.accountLogin({ props.accountLogin({
username, password username, password
}).then(res => {
if (!res.hasError) {
let {from} = props.location.state || {from: {pathname: '/', search: ''}}
history.replace({pathname: from.pathname, search: from.search || ''})
} else {
Toast.info(res.msg, 2, null, false)
}
}) })
// .then(res => {
// if (!res.hasError) {
// let {from} = props.location.state || {from: {pathname: '/', search: ''}}
// history.replace({pathname: from.pathname, search: from.search || ''})
// } else {
// Toast.info(res.msg, 2, null, false)
// }
// })
} }
} }
......
...@@ -65,10 +65,16 @@ class Passport extends Component { ...@@ -65,10 +65,16 @@ class Passport extends Component {
routeWhenUserLoggedIn = () => { routeWhenUserLoggedIn = () => {
let {history} = this.props let {history, location} = this.props
let {data} = this.props.user let {data} = this.props.user
if (data && Object.values(data).filter(item => !!item).length) { if (data && Object.values(data).filter(item => !!item).length) {
(history.action === 'POP' && history.length <= 3) ? history.push('/') : history.go(-1) if(history.action === 'POP' && history.length <= 3) {
history.push('/')
} else {
const { from } = location.state || {from: {pathname: '/', search: ''}};
history.replace(from);
// history.go(-1)
}
} }
} }
......
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