U web update

pull/22/head
vapao 2020-01-10 12:33:03 +08:00
parent 93b2ea011f
commit b585548ef8
3 changed files with 28 additions and 9 deletions

View File

@ -1,8 +1,8 @@
import React from 'react';
import { Form, Input, Icon, Button, Tabs } from 'antd';
import {Form, Input, Icon, Button, Tabs, Modal} from 'antd';
import styles from './login.module.css';
import history from 'libs/history';
import { http } from 'libs';
import {http} from 'libs';
import logo from 'layout/logo.svg';
class LoginIndex extends React.Component {
@ -20,19 +20,34 @@ class LoginIndex extends React.Component {
this.setState({loading: true});
http.post('/api/account/login/', formData)
.then(data => {
localStorage.setItem('token', data['access_token']);
localStorage.setItem('nickname', data['nickname']);
localStorage.setItem('is_supper', data['is_supper']);
if (history.location.state && history.location.state['from']) {
history.push(history.location.state['from'])
if (!data['has_real_ip']) {
Modal.warning({
title: '安全警告',
className: styles.tips,
content: <div>
未能获取到客户端的真实IP无法提供基于请求来源IP的合法性验证详细信息请参考<a target="_blank" href="https://spug.dev">官方文档</a>
</div>,
onOk: () => this.doLogin(data)
})
} else {
history.push('/home')
this.doLogin(data)
}
}, () => this.setState({loading: false}))
}
})
};
doLogin = (data) => {
localStorage.setItem('token', data['access_token']);
localStorage.setItem('nickname', data['nickname']);
localStorage.setItem('is_supper', data['is_supper']);
if (history.location.state && history.location.state['from']) {
history.push(history.location.state['from'])
} else {
history.push('/home')
}
};
render() {
const {getFieldDecorator} = this.props.form;
return (

View File

@ -55,4 +55,8 @@
bottom: 24px;
text-align: center;
color: rgba(0, 0, 0, .45);
}
.tips {
top: 230px
}

View File

@ -2,7 +2,7 @@ const proxy = require('http-proxy-middleware');
module.exports = function (app) {
app.use(proxy('/api/', {
target: 'http://localhost:8000',
target: 'http://127.0.0.1:8000',
changeOrigin: true,
ws: true,
pathRewrite: {