mirror of https://github.com/openspug/spug
U web update
parent
93b2ea011f
commit
b585548ef8
|
@ -1,8 +1,8 @@
|
||||||
import React from 'react';
|
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 styles from './login.module.css';
|
||||||
import history from 'libs/history';
|
import history from 'libs/history';
|
||||||
import { http } from 'libs';
|
import {http} from 'libs';
|
||||||
import logo from 'layout/logo.svg';
|
import logo from 'layout/logo.svg';
|
||||||
|
|
||||||
class LoginIndex extends React.Component {
|
class LoginIndex extends React.Component {
|
||||||
|
@ -20,19 +20,34 @@ class LoginIndex extends React.Component {
|
||||||
this.setState({loading: true});
|
this.setState({loading: true});
|
||||||
http.post('/api/account/login/', formData)
|
http.post('/api/account/login/', formData)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
localStorage.setItem('token', data['access_token']);
|
if (!data['has_real_ip']) {
|
||||||
localStorage.setItem('nickname', data['nickname']);
|
Modal.warning({
|
||||||
localStorage.setItem('is_supper', data['is_supper']);
|
title: '安全警告',
|
||||||
if (history.location.state && history.location.state['from']) {
|
className: styles.tips,
|
||||||
history.push(history.location.state['from'])
|
content: <div>
|
||||||
|
未能获取到客户端的真实IP,无法提供基于请求来源IP的合法性验证,详细信息请参考<a target="_blank" href="https://spug.dev">官方文档</a>。
|
||||||
|
</div>,
|
||||||
|
onOk: () => this.doLogin(data)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
history.push('/home')
|
this.doLogin(data)
|
||||||
}
|
}
|
||||||
}, () => this.setState({loading: false}))
|
}, () => 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() {
|
render() {
|
||||||
const {getFieldDecorator} = this.props.form;
|
const {getFieldDecorator} = this.props.form;
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -56,3 +56,7 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: rgba(0, 0, 0, .45);
|
color: rgba(0, 0, 0, .45);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tips {
|
||||||
|
top: 230px
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ const proxy = require('http-proxy-middleware');
|
||||||
|
|
||||||
module.exports = function (app) {
|
module.exports = function (app) {
|
||||||
app.use(proxy('/api/', {
|
app.use(proxy('/api/', {
|
||||||
target: 'http://localhost:8000',
|
target: 'http://127.0.0.1:8000',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
ws: true,
|
ws: true,
|
||||||
pathRewrite: {
|
pathRewrite: {
|
||||||
|
|
Loading…
Reference in New Issue