Commit f289fea0 by zhanghaozhe

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

parent cbb48655
......@@ -16,7 +16,6 @@ import PasswordInput from '../common/passwordInput'
class AccountLogin extends PureComponent {
render() {
return (
<div className={'account-login'}>
......@@ -75,19 +74,11 @@ const formikConfig = {
})
}
}
const mapStateToProps = state => ({
user: state.user
})
const mapDispatchToProps = {
accountLogin
}
export default compose(
connect(
mapStateToProps,
mapDispatchToProps
state => ({user: state.user}),
{accountLogin}
),
withFormik(formikConfig)
)(AccountLogin)
import React from 'react';
import { Route, Redirect } from "react-router-dom";
import { connect } from "react-redux";
import jsCookie from 'js-cookie'
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 (
<Route {...rest} render={props => {
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