diff --git a/spug_web/src/pages/login/index.js b/spug_web/src/pages/login/index.js index 9868c03..4512f53 100644 --- a/spug_web/src/pages/login/index.js +++ b/spug_web/src/pages/login/index.js @@ -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:
+ 未能获取到客户端的真实IP,无法提供基于请求来源IP的合法性验证,详细信息请参考官方文档。 +
, + 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 ( diff --git a/spug_web/src/pages/login/login.module.css b/spug_web/src/pages/login/login.module.css index 8c8acbe..ea69e04 100644 --- a/spug_web/src/pages/login/login.module.css +++ b/spug_web/src/pages/login/login.module.css @@ -55,4 +55,8 @@ bottom: 24px; text-align: center; color: rgba(0, 0, 0, .45); +} + +.tips { + top: 230px } \ No newline at end of file diff --git a/spug_web/src/setupProxy.js b/spug_web/src/setupProxy.js index 5d9cbcb..2ed7fd0 100644 --- a/spug_web/src/setupProxy.js +++ b/spug_web/src/setupProxy.js @@ -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: {