Commit f289fea0 by zhanghaozhe

添加本地代理服务器cookie设置,privateRoute,登录相关redux逻辑

parent cbb48655
...@@ -15,7 +15,6 @@ import PasswordInput from '../common/passwordInput' ...@@ -15,7 +15,6 @@ import PasswordInput from '../common/passwordInput'
// import LoginWays from '../common/LoginWays' // import LoginWays from '../common/LoginWays'
class AccountLogin extends PureComponent { class AccountLogin extends PureComponent {
render() { render() {
return ( return (
...@@ -75,19 +74,11 @@ const formikConfig = { ...@@ -75,19 +74,11 @@ const formikConfig = {
}) })
} }
} }
const mapStateToProps = state => ({
user: state.user
})
const mapDispatchToProps = {
accountLogin
}
export default compose( export default compose(
connect( connect(
mapStateToProps, state => ({user: state.user}),
mapDispatchToProps {accountLogin}
), ),
withFormik(formikConfig) withFormik(formikConfig)
)(AccountLogin) )(AccountLogin)
import React from 'react'; import React from 'react';
import { Route, Redirect } from "react-router-dom"; import { Route, Redirect } from "react-router-dom";
import { connect } from "react-redux"; import { connect } from "react-redux";
import jsCookie from 'js-cookie'
const PrivateRoute = ({component: Component, path, user, ...rest}) => { const PrivateRoute = ({component: Component, path, user, ...rest}) => {
let authenticated = Object.keys(user.data).some(item => !!user.data[item]) // let authenticated = Object.keys(user.data).some(item => !!user.data[item])
let authenticated = jsCookie.get('token') && jsCookie.get('uid')
return ( return (
<Route {...rest} render={props => { <Route {...rest} render={props => {
return authenticated return authenticated
......
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