feat: 取消cookie记录用户密码的操作

This commit is contained in:
wenbo.dong 2017-07-20 00:29:25 +08:00
parent a8f67cb42f
commit 58d9673114
3 changed files with 2 additions and 47 deletions

View File

@ -5,8 +5,6 @@ import {
GET_LOGIN_STATE
} from '../constants/action-types.js';
import axios from 'axios';
import Cookies from 'universal-cookie';
const cookies = new Cookies();
const checkLoginState = () => {
return {
@ -20,7 +18,6 @@ const loginActions = (data) => {
return (dispatch) => {
axios.post('/user/login', data).then((res) => {
if (res.data.errcode === 0) {
cookies.set(data.email, data.password);
dispatch({
type: LOGIN,
payload: {

View File

@ -3,8 +3,6 @@ import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Form, Button, Input, Icon, Checkbox } from 'antd';
import { loginActions } from '../../actions/login';
import Cookies from 'universal-cookie';
const cookies = new Cookies();
const FormItem = Form.Item;
@connect(
state => {
@ -37,14 +35,6 @@ class Login extends Component {
});
}
handleChange = (value) => {
if (cookies.get(value)) {
this.props.form.setFieldsValue({
password: cookies.get(value)
});
}
}
render() {
const { getFieldDecorator } = this.props.form;
const that = this;
@ -54,10 +44,7 @@ class Login extends Component {
{/* 用户名 (Email) */}
<FormItem>
{getFieldDecorator('email', {
rules: [{ required: true, message: '请输入email!' }],
onChange(e) {
that.handleChange(e.target.value);
}
rules: [{ required: true, message: '请输入email!' }]
})(
<Input prefix={<Icon type="user" style={{ fontSize: 13 }} />} placeholder="Email" />
)}
@ -78,14 +65,6 @@ class Login extends Component {
<Button type="primary" htmlType="submit" className="login-form-button">登录</Button>
</FormItem>
{/* 记住密码 */}
{getFieldDecorator('remember', {
valuePropName: 'checked',
initialValue: true
})(
<Checkbox>记住密码</Checkbox>
)}
</Form>
)
}

View File

@ -3,8 +3,6 @@ import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Form, Button, Input, Icon, Checkbox } from 'antd';
import { loginActions } from '../../actions/login';
import Cookies from 'universal-cookie';
const cookies = new Cookies();
const FormItem = Form.Item;
@connect(
state => {
@ -37,14 +35,6 @@ class Login extends Component {
});
}
handleChange = (value) => {
if (cookies.get(value)) {
this.props.form.setFieldsValue({
password: cookies.get(value)
});
}
}
render() {
const { getFieldDecorator } = this.props.form;
const that = this;
@ -54,10 +44,7 @@ class Login extends Component {
{/* 用户名 (Email) */}
<FormItem>
{getFieldDecorator('email', {
rules: [{ required: true, message: '请输入email!' }],
onChange(e) {
that.handleChange(e.target.value);
}
rules: [{ required: true, message: '请输入email!' }]
})(
<Input prefix={<Icon type="user" style={{ fontSize: 13 }} />} placeholder="Email" />
)}
@ -78,14 +65,6 @@ class Login extends Component {
<Button type="primary" htmlType="submit" className="login-form-button">登录</Button>
</FormItem>
{/* 记住密码 */}
{getFieldDecorator('remember', {
valuePropName: 'checked',
initialValue: true
})(
<Checkbox>记住密码</Checkbox>
)}
</Form>
)
}