mirror of
https://github.com/YMFE/yapi.git
synced 2025-02-23 13:59:28 +08:00
解决冲突
This commit is contained in:
commit
9e6f7d5caf
@ -1,19 +1,26 @@
|
||||
import React, { Component } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Route, HashRouter, Redirect, Switch } from 'react-router-dom'
|
||||
import { Route, HashRouter } from 'react-router-dom'
|
||||
import { Home, ProjectGroups, Interface, News, AddInterface } from './containers/index'
|
||||
import User from './containers/User/User.js'
|
||||
import Header from './components/Header/Header'
|
||||
import { checkLoginState } from './actions/login'
|
||||
import { requireAuthentication } from './components/AuthenticatedComponent';
|
||||
|
||||
const LOADING_STATUS = 0;
|
||||
const GUEST_STATUS = 1;
|
||||
// const MEMBER_STATUS = 2;
|
||||
|
||||
|
||||
class App extends Component {
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return{
|
||||
loginState:state.login.loginState
|
||||
}
|
||||
},
|
||||
{
|
||||
checkLoginState
|
||||
}
|
||||
)
|
||||
export default class App extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
@ -24,59 +31,32 @@ class App extends Component {
|
||||
checkLoginState:PropTypes.func,
|
||||
loginState:PropTypes.number
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.checkLoginState();
|
||||
}
|
||||
route = (status) => {
|
||||
let r;
|
||||
if (status === LOADING_STATUS) {
|
||||
return <span>loading...</span>
|
||||
} else if (status === GUEST_STATUS) {
|
||||
r = (
|
||||
<HashRouter>
|
||||
<div className="router-main">
|
||||
<Header />
|
||||
<Switch>
|
||||
<Route
|
||||
path="/"
|
||||
component={Home}/>
|
||||
<Redirect from="(/:str)" to="/" />
|
||||
</Switch>
|
||||
</div>
|
||||
</HashRouter>
|
||||
)
|
||||
} else {
|
||||
r = (
|
||||
<HashRouter>
|
||||
<div className="router-main">
|
||||
<Header />
|
||||
<Route path="/" component={Home} exact />
|
||||
<Route path="/ProjectGroups" component={ProjectGroups} />
|
||||
<Route path="/Interface" component={Interface} />
|
||||
<Route path="/user" component={User} />
|
||||
<Route path="/News" component={News} />
|
||||
<Route path="/AddInterface" component={ AddInterface } />
|
||||
<Route path="/ProjectGroups" component={requireAuthentication(ProjectGroups)} />
|
||||
<Route path="/Interface" component={requireAuthentication(Interface)} />
|
||||
<Route path="/user" component={requireAuthentication(User)} />
|
||||
<Route path="/News" component={requireAuthentication(News)} />
|
||||
<Route path="/AddInterface" component={ requireAuthentication(AddInterface) } />
|
||||
</div>
|
||||
</HashRouter>
|
||||
)
|
||||
}
|
||||
return r
|
||||
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.checkLoginState();
|
||||
}
|
||||
|
||||
render() {
|
||||
return this.route(this.props.loginState)
|
||||
return this.route(this.props.loginState);
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(
|
||||
state => {
|
||||
return{
|
||||
loginState:state.login.loginState
|
||||
}
|
||||
},
|
||||
{
|
||||
checkLoginState
|
||||
}
|
||||
)(App)
|
||||
|
@ -3,25 +3,28 @@ import {
|
||||
FETCH_MORE_NEWS
|
||||
} from '../constants/action-types.js';
|
||||
|
||||
export function fetchNewsData (logId) {
|
||||
const data = {
|
||||
newsList:[
|
||||
{ key: 1,title: '日志标题', username: 'John Brown', content: '您好!亲爱的用户:您已成功申请接口:实时空气质量数据查询,请于两个月内进行应用验证,逾期接口将不能正常使用。如果您在使用的过程中遇到任何问题,欢迎前往交流社区反馈意见,谢谢!',time: '2014-12-01' },
|
||||
{ key: 2,title: '日志标题', username: 'John Brown', content: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' },
|
||||
{ key: 3,title: '日志标题', username: 'John Brown', content: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' }
|
||||
],
|
||||
totalPage: 34
|
||||
};
|
||||
console.log(logId);
|
||||
import axios from 'axios';
|
||||
import variable from '../constants/variable';
|
||||
|
||||
export function fetchNewsData (uid,page,limit) {
|
||||
// const data = {
|
||||
// newsList:[
|
||||
// { key: 1,title: '日志标题', username: 'John Brown', content: '您好!亲爱的用户:您已成功申请接口:实时空气质量数据查询,请于两个月内进行应用验证,逾期接口将不能正常使用。如果您在使用的过程中遇到任何问题,欢迎前往交流社区反馈意见,谢谢!',time: '2014-12-01' },
|
||||
// { key: 2,title: '日志标题', username: 'John Brown', content: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' },
|
||||
// { key: 3,title: '日志标题', username: 'John Brown', content: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' }
|
||||
// ],
|
||||
// totalPage: 34
|
||||
// };
|
||||
|
||||
const param = {
|
||||
uid: uid,
|
||||
page: page,
|
||||
limit: variable.PAGE_LIMIT?variable.PAGE_LIMIT:limit
|
||||
}
|
||||
console.log(param);
|
||||
return {
|
||||
type: FETCH_NEWS_DATA,
|
||||
payload: new Promise(function(reslove,reject){
|
||||
if(data){
|
||||
reslove(data);
|
||||
}else{
|
||||
reject("chucuole");
|
||||
}
|
||||
})
|
||||
payload: axios.get('/log/list',param)
|
||||
};
|
||||
}
|
||||
|
||||
|
55
client/components/AuthenticatedComponent.js
Normal file
55
client/components/AuthenticatedComponent.js
Normal file
@ -0,0 +1,55 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import PropTypes from 'prop-types'
|
||||
import { changeMenuItem } from '../actions/menu'
|
||||
|
||||
|
||||
export function requireAuthentication(Component) {
|
||||
class AuthenticatedComponent extends React.Component {
|
||||
constructor(props){
|
||||
super(props);
|
||||
}
|
||||
static propTypes ={
|
||||
isAuthenticated : PropTypes.bool,
|
||||
location: PropTypes.object,
|
||||
dispatch: PropTypes.func,
|
||||
history: PropTypes.object,
|
||||
changeMenuItem:PropTypes.func
|
||||
}
|
||||
componentWillMount() {
|
||||
this.checkAuth();
|
||||
}
|
||||
componentWillReceiveProps() {
|
||||
this.checkAuth();
|
||||
}
|
||||
checkAuth() {
|
||||
if( !this.props.isAuthenticated ){
|
||||
this.props.history.push('/');
|
||||
this.props.changeMenuItem('/');
|
||||
}
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
{this.props.isAuthenticated
|
||||
? <Component {...this.props}/>
|
||||
: null
|
||||
}
|
||||
</div>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
return connect(
|
||||
(state) => {
|
||||
return{
|
||||
isAuthenticated: state.login.isLogin
|
||||
}
|
||||
},
|
||||
{
|
||||
changeMenuItem
|
||||
}
|
||||
)(AuthenticatedComponent);
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ import './Footer.scss'
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Icon } from 'antd'
|
||||
|
||||
class Footer extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
@ -11,8 +10,12 @@ class Footer extends Component {
|
||||
footList: PropTypes.array
|
||||
}
|
||||
render () {
|
||||
const style = {
|
||||
'background': 'url(./image/footer-bac.jpg)'
|
||||
}
|
||||
return (
|
||||
<div className = 'footer'>
|
||||
<div className = 'footer' style = {style}>
|
||||
|
||||
<div className = 'footContent'>
|
||||
{ this.props.footList.map(function(item,i){
|
||||
return <FootItem key = { i } linkList = { item.linkList } title = { item.title } iconType = { item.iconType } ></FootItem>
|
||||
@ -22,6 +25,7 @@ class Footer extends Component {
|
||||
YMFF出品 @ YMFF
|
||||
</div>
|
||||
</div>
|
||||
<div className='footerMask'></div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -56,14 +60,7 @@ Footer.defaultProps = {
|
||||
linkList: [
|
||||
{
|
||||
itemTitle: '源码仓库',
|
||||
itemLink: 'http://www.baidu.com'
|
||||
},
|
||||
{
|
||||
itemTitle: '源码仓库1',
|
||||
itemLink: 'http://www.baidu.com'
|
||||
},{
|
||||
itemTitle: '源码仓库2',
|
||||
itemLink: 'www.baidu.com'
|
||||
itemLink: 'http://gitlab.corp.qunar.com/mfe/yapi.git'
|
||||
}
|
||||
]
|
||||
|
||||
@ -73,33 +70,36 @@ Footer.defaultProps = {
|
||||
iconType: 'link',
|
||||
linkList: [
|
||||
{
|
||||
itemTitle: '源码仓库',
|
||||
itemLink: 'www.baidu.com'
|
||||
itemTitle: 'YMFE',
|
||||
itemLink: 'http://ued.qunar.com/ymfe/about'
|
||||
},
|
||||
{
|
||||
itemTitle: '源码仓库1',
|
||||
itemLink: 'www.baidu.com'
|
||||
itemTitle: 'UED',
|
||||
itemLink: 'http://ued.qunar.com/'
|
||||
},{
|
||||
itemTitle: '源码仓库2',
|
||||
itemLink: 'www.baidu.com'
|
||||
itemTitle: '去哪儿网',
|
||||
itemLink: 'http://www.qunar.com/'
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
title: '社区',
|
||||
iconType: 'customer-service',
|
||||
title: '其他项目',
|
||||
iconType: 'layout',
|
||||
linkList: [
|
||||
{
|
||||
itemTitle: '源码仓库',
|
||||
itemLink: 'www.baidu.com'
|
||||
itemTitle: 'Yo',
|
||||
itemLink: 'http://ued.qunar.com/hy2/yo/'
|
||||
},
|
||||
{
|
||||
itemTitle: '源码仓库1',
|
||||
itemLink: 'www.baidu.com'
|
||||
itemTitle: 'YIcon',
|
||||
itemLink: 'http://ued.qunar.com/yicon/'
|
||||
},{
|
||||
itemTitle: '源码仓库2',
|
||||
itemLink: 'www.baidu.com'
|
||||
itemTitle: 'YKit',
|
||||
itemLink: 'http://ued.qunar.com/ykit/'
|
||||
},{
|
||||
itemTitle: 'YDoc',
|
||||
itemLink: 'http://ued.qunar.com/ydoc/'
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
.footer{
|
||||
// max-width: 12rem;
|
||||
margin: 20px auto;
|
||||
margin: 0px auto;
|
||||
clear: both;
|
||||
font-size: 12px;
|
||||
background: #000c15;
|
||||
@ -10,7 +10,9 @@
|
||||
z-index: 1;
|
||||
color: rgba(255,255,255,.65);
|
||||
box-shadow: 0 1000px 0 1000px #fff;
|
||||
|
||||
// background-image: url('image/footer-bac.jpg');
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
h4{
|
||||
margin-bottom: 20px;
|
||||
color: #FFF;
|
||||
@ -19,23 +21,38 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
.footerMask{
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background-color: #404040;
|
||||
opacity: .65;
|
||||
z-index: 1;
|
||||
}
|
||||
.footContent{
|
||||
max-width: 11rem;
|
||||
width:90%;
|
||||
margin:0px auto;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
.footItem{
|
||||
padding: 24px 2%;
|
||||
width: 25%;
|
||||
float: left;
|
||||
|
||||
a{
|
||||
div{
|
||||
margin: 6px 0px;
|
||||
display: block;
|
||||
}
|
||||
a{
|
||||
font-weight: 200;
|
||||
color: #108ee9;
|
||||
&:hover{
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
.copyRight{
|
||||
padding: 24px 2%;
|
||||
|
@ -85,16 +85,9 @@ class HeaderCom extends Component {
|
||||
}
|
||||
linkTo = (e) =>{
|
||||
this.props.changeMenuItem(e.key);
|
||||
// this.props.curKey = e.key;
|
||||
// this.setState({
|
||||
// current : e.key
|
||||
// })
|
||||
}
|
||||
relieveLink = () => {
|
||||
this.props.changeMenuItem("");
|
||||
// this.setState({
|
||||
// current : ""
|
||||
// })
|
||||
}
|
||||
logout = (e) => {
|
||||
e.preventDefault();
|
||||
@ -129,9 +122,10 @@ class HeaderCom extends Component {
|
||||
}
|
||||
render () {
|
||||
const { login, user, msg, uid, curKey } = this.props;
|
||||
console.log(curKey);
|
||||
return (
|
||||
<acticle className="header-box">
|
||||
<Layout className="'layout">
|
||||
<Layout className="layout">
|
||||
<Header>
|
||||
<div className="content">
|
||||
<div className="logo">
|
||||
|
@ -4,6 +4,16 @@ import { connect } from 'react-redux';
|
||||
import { Form, Button, Input, Icon, message } from 'antd';
|
||||
import { loginActions } from '../../actions/login';
|
||||
const FormItem = Form.Item;
|
||||
import './Login.scss'
|
||||
|
||||
const formItemStyle = {
|
||||
marginBottom: '.16rem'
|
||||
}
|
||||
|
||||
const changeHeight = {
|
||||
height: '.42rem'
|
||||
}
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
@ -49,29 +59,29 @@ class Login extends Component {
|
||||
<Form onSubmit={this.handleSubmit}>
|
||||
|
||||
{/* 用户名 (Email) */}
|
||||
<FormItem>
|
||||
<FormItem style={formItemStyle}>
|
||||
{getFieldDecorator('email', {
|
||||
rules: [{ required: true, message: '请输入email!' }]
|
||||
})(
|
||||
<Input prefix={<Icon type="user" style={{ fontSize: 13 }} />} placeholder="Email" />
|
||||
<Input style={changeHeight} prefix={<Icon type="user" style={{ fontSize: 13 }} />} placeholder="Email" />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
{/* 密码 */}
|
||||
<FormItem>
|
||||
<FormItem style={formItemStyle}>
|
||||
{getFieldDecorator('password', {
|
||||
rules: [{ required: true, message: '请输入密码!' }]
|
||||
})(
|
||||
<Input prefix={<Icon type="lock" style={{ fontSize: 13 }} />} type="password" placeholder="Password" />
|
||||
<Input style={changeHeight} prefix={<Icon type="lock" style={{ fontSize: 13 }} />} type="password" placeholder="Password" />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
|
||||
{/* 登录按钮 */}
|
||||
<FormItem>
|
||||
<Button type="primary" htmlType="submit" className="login-form-button">登录</Button>
|
||||
<FormItem style={formItemStyle}>
|
||||
<Button style={changeHeight} type="primary" htmlType="submit" className="login-form-button">登录</Button>
|
||||
</FormItem>
|
||||
<Button id="qsso-login" type="primary" className="login-form-button" onClick={() => window.QSSO.attach('qsso-login','/user/login_by_token')}>QSSO登录</Button>
|
||||
<Button style={changeHeight} id="qsso-login" type="primary" className="login-form-button" size="large" onClick={() => window.QSSO.attach('qsso-login','/user/login_by_token')} ghost>QSSO登录</Button>
|
||||
</Form>
|
||||
|
||||
)
|
||||
|
@ -1,4 +1,16 @@
|
||||
@import '../../styles/common.scss';
|
||||
|
||||
/* .login-main.css */
|
||||
.ant-tabs-nav-wrap {
|
||||
font-size: .16rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.login-form-button {
|
||||
// background-image: linear-gradient(to right, #4facfe 0%, #00f2fe 100%) !important;
|
||||
// border: none !important;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ant-form-item{
|
||||
margin-bottom: .1rem;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
import './Login.scss'
|
||||
import React, { Component } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Tabs } from 'antd';
|
||||
import LoginForm from './Login';
|
||||
import RegForm from './Reg';
|
||||
import './Login.scss';
|
||||
const TabPane = Tabs.TabPane;
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ class LoginWrap extends Component {
|
||||
render() {
|
||||
const { loginWrapActiveKey } = this.props;
|
||||
return (
|
||||
<Tabs defaultActiveKey={loginWrapActiveKey} className="login-form">
|
||||
<Tabs defaultActiveKey={loginWrapActiveKey} className="login-form" tabBarStyle={{border: 'none'}}>
|
||||
<TabPane tab="登录" key="1">
|
||||
<LoginForm/>
|
||||
</TabPane>
|
||||
|
@ -5,6 +5,14 @@ import { Form, Button, Input, Icon, message } from 'antd';
|
||||
import { regActions } from '../../actions/login';
|
||||
|
||||
const FormItem = Form.Item;
|
||||
const formItemStyle = {
|
||||
marginBottom: '.16rem'
|
||||
}
|
||||
|
||||
const changeHeight = {
|
||||
height: '.42rem'
|
||||
}
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
@ -75,25 +83,25 @@ class Reg extends Component {
|
||||
<Form onSubmit={this.handleSubmit}>
|
||||
|
||||
{/* 用户名 */}
|
||||
<FormItem>
|
||||
<FormItem style={formItemStyle}>
|
||||
{getFieldDecorator('userName', {
|
||||
rules: [{ required: true, message: '请输入用户名!' }]
|
||||
})(
|
||||
<Input prefix={<Icon type="user" style={{ fontSize: 13 }} />} placeholder="Username" />
|
||||
<Input style={changeHeight} prefix={<Icon type="user" style={{ fontSize: 13 }} />} placeholder="Username" />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
{/* Emaiil */}
|
||||
<FormItem>
|
||||
<FormItem style={formItemStyle}>
|
||||
{getFieldDecorator('email', {
|
||||
rules: [{ required: true, message: '请输入email!' }]
|
||||
})(
|
||||
<Input prefix={<Icon type="user" style={{ fontSize: 13 }} />} placeholder="Email" />
|
||||
<Input style={changeHeight} prefix={<Icon type="user" style={{ fontSize: 13 }} />} placeholder="Email" />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
{/* 密码 */}
|
||||
<FormItem>
|
||||
<FormItem style={formItemStyle}>
|
||||
{getFieldDecorator('password', {
|
||||
rules: [{
|
||||
required: true,
|
||||
@ -102,12 +110,12 @@ class Reg extends Component {
|
||||
validator: this.checkConfirm
|
||||
}]
|
||||
})(
|
||||
<Input prefix={<Icon type="lock" style={{ fontSize: 13 }} />} type="password" placeholder="Password" />
|
||||
<Input style={changeHeight} prefix={<Icon type="lock" style={{ fontSize: 13 }} />} type="password" placeholder="Password" />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
{/* 密码二次确认 */}
|
||||
<FormItem>
|
||||
<FormItem style={formItemStyle}>
|
||||
{getFieldDecorator('confirm', {
|
||||
rules: [{
|
||||
required: true,
|
||||
@ -116,13 +124,13 @@ class Reg extends Component {
|
||||
validator: this.checkPassword
|
||||
}]
|
||||
})(
|
||||
<Input prefix={<Icon type="lock" style={{ fontSize: 13 }} />} type="password" placeholder="Confirm Password" />
|
||||
<Input style={changeHeight} prefix={<Icon type="lock" style={{ fontSize: 13 }} />} type="password" placeholder="Confirm Password" />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
{/* 注册按钮 */}
|
||||
<FormItem>
|
||||
<Button type="primary" htmlType="submit" className="login-form-button">注册</Button>
|
||||
<FormItem style={formItemStyle}>
|
||||
<Button style={changeHeight} type="primary" htmlType="submit" className="login-form-button">注册</Button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
)
|
||||
|
@ -10,6 +10,7 @@ import { fetchNewsData } from '../../actions/news.js'
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
uid: state.user.curUid,
|
||||
newsData: state.news.newsData?state.news.newsData:[]
|
||||
}
|
||||
},
|
||||
@ -27,7 +28,8 @@ class News extends Component {
|
||||
}
|
||||
static propTypes = {
|
||||
newsData: PropTypes.object,
|
||||
fetchNewsData: PropTypes.func
|
||||
fetchNewsData: PropTypes.func,
|
||||
uid: PropTypes.string
|
||||
}
|
||||
setLoading(bool){
|
||||
this.setState({
|
||||
@ -35,7 +37,10 @@ class News extends Component {
|
||||
})
|
||||
}
|
||||
componentWillMount(){
|
||||
this.props.fetchNewsData()
|
||||
console.log(this.props.uid);
|
||||
this.props.fetchNewsData(1,1,10).then(function(data){
|
||||
console.log(data);
|
||||
})
|
||||
}
|
||||
render () {
|
||||
const data = this.props.newsData
|
||||
|
@ -18,7 +18,9 @@ const logList = [{
|
||||
}];
|
||||
@connect(
|
||||
state => {
|
||||
// console.log(state);
|
||||
return {
|
||||
uid: state.user.curUid,
|
||||
newsData: state.news.newsData
|
||||
}
|
||||
},
|
||||
@ -31,7 +33,8 @@ class NewsList extends Component {
|
||||
|
||||
static propTypes = {
|
||||
fetchNewsData: PropTypes.func,
|
||||
setLoading: PropTypes.func
|
||||
setLoading: PropTypes.func,
|
||||
uid: PropTypes.string
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
@ -48,7 +51,8 @@ class NewsList extends Component {
|
||||
})
|
||||
const that = this;
|
||||
this.props.setLoading(true);
|
||||
this.props.fetchNewsData(+e.key).then(function(){
|
||||
this.props.fetchNewsData(+this.props.uid,0,5).then(function(data){
|
||||
console.log(data.data);
|
||||
that.props.setLoading(false);
|
||||
})
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class NewsTimeline extends Component {
|
||||
<section className="news-timeline">
|
||||
<span className='removeAllNews'>
|
||||
<Popconfirm title="你确定要清空所有消息吗?" onConfirm={removeConfirm} okText="删除" cancelText="取消">
|
||||
清空消息
|
||||
项目日志
|
||||
</Popconfirm>
|
||||
</span>
|
||||
<Table
|
||||
|
@ -3,7 +3,7 @@ import {
|
||||
} from '../../constants/action-types.js'
|
||||
|
||||
const initialState = {
|
||||
curKey: window.location.hash.split("#")[1]
|
||||
curKey: window.location.hash.split("#")[1] || '/'
|
||||
}
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
|
@ -10,6 +10,7 @@ const initialState = {
|
||||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case FETCH_NEWS_DATA: {
|
||||
// console.log(action.payload);
|
||||
return {
|
||||
...state,
|
||||
newsData: action.payload
|
||||
|
@ -48,6 +48,10 @@ class interfaceController extends baseController{
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '接口请求路径不能为空');
|
||||
}
|
||||
|
||||
if(!yapi.commons.verifyPath(params.path)){
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '接口path第一位必须是/,最后一位不能为/')
|
||||
}
|
||||
|
||||
let checkRepeat = await this.Model.checkRepeat(params.path, params.method);
|
||||
if(checkRepeat > 0){
|
||||
return ctx.body = yapi.commons.resReturn(null, 401, '已存在的接口:' + params.path + '[' + params.method + ']');
|
||||
@ -162,12 +166,17 @@ class interfaceController extends baseController{
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '接口id不能为空');
|
||||
}
|
||||
let interfaceData = await this.Model.get(id);
|
||||
|
||||
if(params.path && !yapi.commons.verifyPath(params.path)){
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '接口path第一位必须是/,最后一位不能为/')
|
||||
}
|
||||
|
||||
if(params.path && params.path !== interfaceData.path && params.method !== interfaceData.method){
|
||||
let checkRepeat = await this.Model.checkRepeat(params.path, params.method);
|
||||
if(checkRepeat > 0){
|
||||
return ctx.body = yapi.commons.resReturn(null, 401, '已存在的接口:' + params.path + '[' + params.method + ']');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let data = {
|
||||
up_time: yapi.commons.time()
|
||||
|
@ -18,20 +18,12 @@ class projectController extends baseController {
|
||||
if(!basepath) return false;
|
||||
if(basepath[0] !== '/') basepath = '/' + basepath;
|
||||
if(basepath[basepath.length -1] === '/') basepath = basepath.substr(0, basepath.length -1)
|
||||
if(!this.verifyPath(basepath)){
|
||||
if(!yapi.commons.verifyPath(basepath)){
|
||||
return false;
|
||||
}
|
||||
return basepath;
|
||||
}
|
||||
|
||||
verifyPath(path){
|
||||
if(/^[a-zA-Z0-9\-\/_:]+$/.test(path)){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
verifyDomain(domain){
|
||||
if(!domain) return false;
|
||||
if(/^[a-zA-Z0-9\-_\.]+[a-zA-Z]{2,6}$/.test(domain)){
|
||||
@ -51,8 +43,8 @@ class projectController extends baseController {
|
||||
* @param {String} prd_host 项目线上域名,不能为空。可通过配置的域名访问到mock数据
|
||||
* @param {String} protocol 线上域名协议,不能为空
|
||||
* @param {Number} group_id 项目分组id,不能为空
|
||||
* @param {String} [desc] 项目描述
|
||||
* @returns {Object}
|
||||
* @param {String} [desc] 项目描述
|
||||
* @returns {Object}
|
||||
* @example ./api/project/add.json
|
||||
*/
|
||||
async add(ctx) {
|
||||
@ -90,7 +82,7 @@ class projectController extends baseController {
|
||||
if(checkRepeatDomain > 0){
|
||||
return ctx.body = yapi.commons.resReturn(null, 401, '已存在domain和basepath');
|
||||
}
|
||||
|
||||
|
||||
let data = {
|
||||
name: params.name,
|
||||
desc: params.desc,
|
||||
@ -105,12 +97,12 @@ class projectController extends baseController {
|
||||
}
|
||||
|
||||
try{
|
||||
let result = await this.Model.save(data);
|
||||
let result = await this.Model.save(data);
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
}catch(e){
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* 添加项目
|
||||
@ -120,7 +112,7 @@ class projectController extends baseController {
|
||||
* @foldnumber 10
|
||||
* @param {Number} id 项目id,不能为空
|
||||
* @param {String} member_uid 项目成员uid,不能为空
|
||||
* @returns {Object}
|
||||
* @returns {Object}
|
||||
* @example ./api/project/add_member.json
|
||||
*/
|
||||
async addMember(ctx){
|
||||
@ -152,7 +144,7 @@ class projectController extends baseController {
|
||||
* @foldnumber 10
|
||||
* @param {Number} id 项目id,不能为空
|
||||
* @param {member_uid} uid 项目成员uid,不能为空
|
||||
* @returns {Object}
|
||||
* @returns {Object}
|
||||
* @example ./api/project/del_member.json
|
||||
*/
|
||||
|
||||
@ -212,7 +204,7 @@ class projectController extends baseController {
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @param {Number} id 项目id,不能为空
|
||||
* @returns {Object}
|
||||
* @returns {Object}
|
||||
* @example ./api/project/get.json
|
||||
*/
|
||||
|
||||
@ -238,7 +230,7 @@ class projectController extends baseController {
|
||||
* @param {Number} group_id 项目group_id,不能为空
|
||||
* @param {Number} [page] 分页页码
|
||||
* @param {Number} [limit] 每页数据条目,默认为10
|
||||
* @returns {Object}
|
||||
* @returns {Object}
|
||||
* @example ./api/project/list.json
|
||||
*/
|
||||
|
||||
@ -256,12 +248,11 @@ class projectController extends baseController {
|
||||
let count = await this.Model.listCount(group_id);
|
||||
let uids = [];
|
||||
result.forEach( (item)=> {
|
||||
if(uids.indexOf(item.uid) !== -1){
|
||||
if(uids.indexOf(item.uid) === -1){
|
||||
uids.push(item.uid)
|
||||
}
|
||||
|
||||
} )
|
||||
|
||||
} )
|
||||
let _users = {}, users = await yapi.getInst(userModel).findByUids(uids);
|
||||
users.forEach((item)=> {
|
||||
_users[item._id] = item;
|
||||
@ -271,7 +262,7 @@ class projectController extends baseController {
|
||||
list: result,
|
||||
userinfo: _users
|
||||
})
|
||||
}catch(err){
|
||||
}catch(e){
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message)
|
||||
}
|
||||
}
|
||||
@ -283,11 +274,11 @@ class projectController extends baseController {
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @param {Number} id 项目id,不能为空
|
||||
* @returns {Object}
|
||||
* @returns {Object}
|
||||
* @example ./api/project/del.json
|
||||
*/
|
||||
|
||||
async del(ctx){
|
||||
async del(ctx){
|
||||
try{
|
||||
let id = ctx.request.body.id;
|
||||
if(!id){
|
||||
@ -319,16 +310,16 @@ class projectController extends baseController {
|
||||
* @param {String} name 项目名称,不能为空
|
||||
* @param {String} basepath 项目基本路径,不能为空
|
||||
* @param {String} prd_host 项目线上域名,不能为空。可通过配置的域名访问到mock数据
|
||||
* @param {String} [desc] 项目描述
|
||||
* @param {String} [desc] 项目描述
|
||||
* @param {Array} [env] 项目环境配置
|
||||
* @param {String} [env[].name] 环境名称
|
||||
* @param {String} [env[].domain] 环境域名
|
||||
* @returns {Object}
|
||||
* @returns {Object}
|
||||
* @example ./api/project/up.json
|
||||
*/
|
||||
|
||||
async up(ctx){
|
||||
try{
|
||||
try{
|
||||
let id = ctx.request.body.id;
|
||||
let params = ctx.request.body;
|
||||
if(!id){
|
||||
@ -338,7 +329,7 @@ class projectController extends baseController {
|
||||
if(await this.jungeMemberAuth(id, this.getUid()) !== true){
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
|
||||
}
|
||||
|
||||
|
||||
let projectData = await this.Model.get(id);
|
||||
|
||||
if(params.basepath = (this.handleBasepath(params.basepath)) === false){
|
||||
@ -348,7 +339,7 @@ class projectController extends baseController {
|
||||
if(!this.verifyDomain(params.prd_host)){
|
||||
return ctx.body = yapi.commons.resReturn(null, 401, '线上域名格式有误')
|
||||
}
|
||||
|
||||
|
||||
if(projectData.name === params.name){
|
||||
delete params.name;
|
||||
}
|
||||
@ -435,7 +426,7 @@ class projectController extends baseController {
|
||||
{ key: 'add_time', alias: 'addTime' },
|
||||
{ key: 'up_time', alias: 'upTime' }
|
||||
];
|
||||
|
||||
|
||||
projectList = commons.filterRes(projectList, projectRules);
|
||||
groupList = commons.filterRes(groupList, groupRules);
|
||||
|
||||
@ -443,9 +434,9 @@ class projectController extends baseController {
|
||||
project: projectList,
|
||||
group: groupList
|
||||
};
|
||||
|
||||
|
||||
return ctx.body = yapi.commons.resReturn(queryList, 0, 'ok')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = projectController;
|
||||
module.exports = projectController;
|
||||
|
@ -139,6 +139,10 @@ class userController extends baseController {
|
||||
up_time: yapi.commons.time()
|
||||
}
|
||||
user = await userInst.save(data);
|
||||
yapi.commons.sendMail({
|
||||
to: params.email,
|
||||
contents: `<h3>亲爱的用户:</h3><p>您好,感谢使用YApi,系统检测您是第一次用Qsso账号登录YApi服务,您的Email是: ${params.email} ,初始化密码为:${passsalt}</p>`
|
||||
})
|
||||
}
|
||||
|
||||
this.setLoginCookie(user._id, user.passsalt)
|
||||
@ -276,7 +280,7 @@ class userController extends baseController {
|
||||
});
|
||||
yapi.commons.sendMail({
|
||||
to: params.email,
|
||||
contents: `欢迎注册,您的账号 ${params.email} 已经注册成功`
|
||||
contents: `<h3>亲爱的用户:</h3><p>您好,感谢使用YApi,您的账号 ${params.email} 已经注册成功</p>`
|
||||
})
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 401, e.message);
|
||||
|
@ -18,6 +18,12 @@ class logModel extends baseModel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {String} title log标题
|
||||
* @param {String} content log内容
|
||||
* @param {Enum} type log类型, ['user', 'group', 'interface', 'project', 'other']
|
||||
* @param {Number} uid 用户id
|
||||
*/
|
||||
async save(data) {
|
||||
let userInst = yapi.getInst(userModel);
|
||||
let username = await userInst.findById(data.uid);
|
||||
|
@ -41,7 +41,7 @@ class userModel extends baseModel{
|
||||
}
|
||||
findByUids(uids){
|
||||
return this.model.find({
|
||||
_id: {$in: [107]}
|
||||
_id: {$in: uids}
|
||||
}).select("_id username email role add_time up_time").exec()
|
||||
}
|
||||
listWithPaging(page, limit) {
|
||||
|
@ -134,4 +134,16 @@ exports.filterRes = (list, rules) => {
|
||||
});
|
||||
return filteredRes;
|
||||
})
|
||||
}
|
||||
|
||||
exports.verifyPath = (path) => {
|
||||
if (/^\/[a-zA-Z0-9\-\/_:]+$/.test(path)) {
|
||||
if (path[path.length - 1] === '/') {
|
||||
return false;
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -114,21 +114,29 @@ var interfaceController = function (_baseController) {
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '接口请求路径不能为空'));
|
||||
|
||||
case 8:
|
||||
_context.next = 10;
|
||||
return this.Model.checkRepeat(params.path, params.method);
|
||||
if (_yapi2.default.commons.verifyPath(params.path)) {
|
||||
_context.next = 10;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '接口path第一位必须是/,最后一位不能为/'));
|
||||
|
||||
case 10:
|
||||
_context.next = 12;
|
||||
return this.Model.checkRepeat(params.path, params.method);
|
||||
|
||||
case 12:
|
||||
checkRepeat = _context.sent;
|
||||
|
||||
if (!(checkRepeat > 0)) {
|
||||
_context.next = 13;
|
||||
_context.next = 15;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '已存在的接口:' + params.path + '[' + params.method + ']'));
|
||||
|
||||
case 13:
|
||||
_context.prev = 13;
|
||||
case 15:
|
||||
_context.prev = 15;
|
||||
data = {
|
||||
project_id: params.project_id,
|
||||
title: params.title,
|
||||
@ -148,28 +156,28 @@ var interfaceController = function (_baseController) {
|
||||
if (params.req_params_form) data.req_params_form = params.req_params_form;
|
||||
if (params.req_params_other) data.req_params_other = params.req_params_other;
|
||||
|
||||
_context.next = 19;
|
||||
_context.next = 21;
|
||||
return this.Model.save(data);
|
||||
|
||||
case 19:
|
||||
case 21:
|
||||
result = _context.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 26;
|
||||
_context.next = 28;
|
||||
break;
|
||||
|
||||
case 23:
|
||||
_context.prev = 23;
|
||||
_context.t0 = _context['catch'](13);
|
||||
case 25:
|
||||
_context.prev = 25;
|
||||
_context.t0 = _context['catch'](15);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
|
||||
|
||||
case 26:
|
||||
case 28:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this, [[13, 23]]);
|
||||
}, _callee, this, [[15, 25]]);
|
||||
}));
|
||||
|
||||
function add(_x) {
|
||||
@ -359,25 +367,33 @@ var interfaceController = function (_baseController) {
|
||||
case 8:
|
||||
interfaceData = _context4.sent;
|
||||
|
||||
if (!(params.path && params.path !== interfaceData.path && params.method !== interfaceData.method)) {
|
||||
_context4.next = 15;
|
||||
if (!(params.path && !_yapi2.default.commons.verifyPath(params.path))) {
|
||||
_context4.next = 11;
|
||||
break;
|
||||
}
|
||||
|
||||
_context4.next = 12;
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '接口path第一位必须是/,最后一位不能为/'));
|
||||
|
||||
case 11:
|
||||
if (!(params.path && params.path !== interfaceData.path && params.method !== interfaceData.method)) {
|
||||
_context4.next = 17;
|
||||
break;
|
||||
}
|
||||
|
||||
_context4.next = 14;
|
||||
return this.Model.checkRepeat(params.path, params.method);
|
||||
|
||||
case 12:
|
||||
case 14:
|
||||
checkRepeat = _context4.sent;
|
||||
|
||||
if (!(checkRepeat > 0)) {
|
||||
_context4.next = 15;
|
||||
_context4.next = 17;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '已存在的接口:' + params.path + '[' + params.method + ']'));
|
||||
|
||||
case 15:
|
||||
case 17:
|
||||
data = {
|
||||
up_time: _yapi2.default.commons.time()
|
||||
};
|
||||
@ -396,29 +412,29 @@ var interfaceController = function (_baseController) {
|
||||
if (params.res_body_type) data.res_body_type = params.res_body_type;
|
||||
if (params.res_body) data.res_body = params.res_body;
|
||||
|
||||
_context4.prev = 25;
|
||||
_context4.next = 28;
|
||||
_context4.prev = 27;
|
||||
_context4.next = 30;
|
||||
return this.Model.up(id, data);
|
||||
|
||||
case 28:
|
||||
case 30:
|
||||
result = _context4.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context4.next = 35;
|
||||
_context4.next = 37;
|
||||
break;
|
||||
|
||||
case 32:
|
||||
_context4.prev = 32;
|
||||
_context4.t0 = _context4['catch'](25);
|
||||
case 34:
|
||||
_context4.prev = 34;
|
||||
_context4.t0 = _context4['catch'](27);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context4.t0.message);
|
||||
|
||||
case 35:
|
||||
case 37:
|
||||
case 'end':
|
||||
return _context4.stop();
|
||||
}
|
||||
}
|
||||
}, _callee4, this, [[25, 32]]);
|
||||
}, _callee4, this, [[27, 34]]);
|
||||
}));
|
||||
|
||||
function up(_x4) {
|
||||
|
@ -77,20 +77,11 @@ var projectController = function (_baseController) {
|
||||
if (!basepath) return false;
|
||||
if (basepath[0] !== '/') basepath = '/' + basepath;
|
||||
if (basepath[basepath.length - 1] === '/') basepath = basepath.substr(0, basepath.length - 1);
|
||||
if (!this.verifyPath(basepath)) {
|
||||
if (!_yapi2.default.commons.verifyPath(basepath)) {
|
||||
return false;
|
||||
}
|
||||
return basepath;
|
||||
}
|
||||
}, {
|
||||
key: 'verifyPath',
|
||||
value: function verifyPath(path) {
|
||||
if (/^[a-zA-Z0-9\-\/_:]+$/.test(path)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'verifyDomain',
|
||||
value: function verifyDomain(domain) {
|
||||
@ -112,8 +103,8 @@ var projectController = function (_baseController) {
|
||||
* @param {String} prd_host 项目线上域名,不能为空。可通过配置的域名访问到mock数据
|
||||
* @param {String} protocol 线上域名协议,不能为空
|
||||
* @param {Number} group_id 项目分组id,不能为空
|
||||
* @param {String} [desc] 项目描述
|
||||
* @returns {Object}
|
||||
* @param {String} [desc] 项目描述
|
||||
* @returns {Object}
|
||||
* @example ./api/project/add.json
|
||||
*/
|
||||
|
||||
@ -255,7 +246,7 @@ var projectController = function (_baseController) {
|
||||
* @foldnumber 10
|
||||
* @param {Number} id 项目id,不能为空
|
||||
* @param {String} member_uid 项目成员uid,不能为空
|
||||
* @returns {Object}
|
||||
* @returns {Object}
|
||||
* @example ./api/project/add_member.json
|
||||
*/
|
||||
|
||||
@ -339,7 +330,7 @@ var projectController = function (_baseController) {
|
||||
* @foldnumber 10
|
||||
* @param {Number} id 项目id,不能为空
|
||||
* @param {member_uid} uid 项目成员uid,不能为空
|
||||
* @returns {Object}
|
||||
* @returns {Object}
|
||||
* @example ./api/project/del_member.json
|
||||
*/
|
||||
|
||||
@ -492,7 +483,7 @@ var projectController = function (_baseController) {
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @param {Number} id 项目id,不能为空
|
||||
* @returns {Object}
|
||||
* @returns {Object}
|
||||
* @example ./api/project/get.json
|
||||
*/
|
||||
|
||||
@ -556,7 +547,7 @@ var projectController = function (_baseController) {
|
||||
* @param {Number} group_id 项目group_id,不能为空
|
||||
* @param {Number} [page] 分页页码
|
||||
* @param {Number} [limit] 每页数据条目,默认为10
|
||||
* @returns {Object}
|
||||
* @returns {Object}
|
||||
* @example ./api/project/list.json
|
||||
*/
|
||||
|
||||
@ -594,11 +585,10 @@ var projectController = function (_baseController) {
|
||||
uids = [];
|
||||
|
||||
result.forEach(function (item) {
|
||||
if (uids.indexOf(item.uid) !== -1) {
|
||||
if (uids.indexOf(item.uid) === -1) {
|
||||
uids.push(item.uid);
|
||||
}
|
||||
});
|
||||
|
||||
_users = {};
|
||||
_context6.next = 15;
|
||||
return _yapi2.default.getInst(_user2.default).findByUids(uids);
|
||||
@ -621,7 +611,7 @@ var projectController = function (_baseController) {
|
||||
_context6.prev = 20;
|
||||
_context6.t0 = _context6['catch'](3);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, e.message);
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context6.t0.message);
|
||||
|
||||
case 23:
|
||||
case 'end':
|
||||
@ -645,7 +635,7 @@ var projectController = function (_baseController) {
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @param {Number} id 项目id,不能为空
|
||||
* @returns {Object}
|
||||
* @returns {Object}
|
||||
* @example ./api/project/del.json
|
||||
*/
|
||||
|
||||
@ -739,11 +729,11 @@ var projectController = function (_baseController) {
|
||||
* @param {String} name 项目名称,不能为空
|
||||
* @param {String} basepath 项目基本路径,不能为空
|
||||
* @param {String} prd_host 项目线上域名,不能为空。可通过配置的域名访问到mock数据
|
||||
* @param {String} [desc] 项目描述
|
||||
* @param {String} [desc] 项目描述
|
||||
* @param {Array} [env] 项目环境配置
|
||||
* @param {String} [env[].name] 环境名称
|
||||
* @param {String} [env[].domain] 环境域名
|
||||
* @returns {Object}
|
||||
* @returns {Object}
|
||||
* @example ./api/project/up.json
|
||||
*/
|
||||
|
||||
|
@ -301,7 +301,7 @@ var userController = function (_baseController) {
|
||||
user = _context4.sent;
|
||||
|
||||
if (!(!user || !user._id)) {
|
||||
_context4.next = 12;
|
||||
_context4.next = 13;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -321,24 +321,29 @@ var userController = function (_baseController) {
|
||||
case 11:
|
||||
user = _context4.sent;
|
||||
|
||||
case 12:
|
||||
_yapi2.default.commons.sendMail({
|
||||
to: params.email,
|
||||
contents: '<h3>\u4EB2\u7231\u7684\u7528\u6237\uFF1A</h3><p>\u60A8\u597D\uFF0C\u611F\u8C22\u4F7F\u7528YApi,\u7CFB\u7EDF\u68C0\u6D4B\u60A8\u662F\u7B2C\u4E00\u6B21\u7528Qsso\u8D26\u53F7\u767B\u5F55YApi\u670D\u52A1,\u60A8\u7684Email\u662F\uFF1A ' + params.email + ' \uFF0C\u521D\u59CB\u5316\u5BC6\u7801\u4E3A\uFF1A' + passsalt + '</p>'
|
||||
});
|
||||
|
||||
case 13:
|
||||
|
||||
this.setLoginCookie(user._id, user.passsalt);
|
||||
return _context4.abrupt('return', true);
|
||||
|
||||
case 16:
|
||||
_context4.prev = 16;
|
||||
case 17:
|
||||
_context4.prev = 17;
|
||||
_context4.t0 = _context4['catch'](2);
|
||||
|
||||
console.error(_context4.t0.message);
|
||||
return _context4.abrupt('return', false);
|
||||
|
||||
case 20:
|
||||
case 21:
|
||||
case 'end':
|
||||
return _context4.stop();
|
||||
}
|
||||
}
|
||||
}, _callee4, this, [[2, 16]]);
|
||||
}, _callee4, this, [[2, 17]]);
|
||||
}));
|
||||
|
||||
function handleThirdLogin(_x4, _x5) {
|
||||
@ -605,7 +610,7 @@ var userController = function (_baseController) {
|
||||
});
|
||||
_yapi2.default.commons.sendMail({
|
||||
to: params.email,
|
||||
contents: '\u6B22\u8FCE\u6CE8\u518C\uFF0C\u60A8\u7684\u8D26\u53F7 ' + params.email + ' \u5DF2\u7ECF\u6CE8\u518C\u6210\u529F'
|
||||
contents: '<h3>\u4EB2\u7231\u7684\u7528\u6237\uFF1A</h3><p>\u60A8\u597D\uFF0C\u611F\u8C22\u4F7F\u7528YApi,\u60A8\u7684\u8D26\u53F7 ' + params.email + ' \u5DF2\u7ECF\u6CE8\u518C\u6210\u529F</p>'
|
||||
});
|
||||
_context8.next = 26;
|
||||
break;
|
||||
@ -855,15 +860,16 @@ var userController = function (_baseController) {
|
||||
key: 'update',
|
||||
value: function () {
|
||||
var _ref12 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee12(ctx) {
|
||||
var params, userInst, id, data, checkRepeat, result;
|
||||
var _params, userInst, id, data, checkRepeat, result;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee12$(_context12) {
|
||||
while (1) {
|
||||
switch (_context12.prev = _context12.next) {
|
||||
case 0:
|
||||
_context12.prev = 0;
|
||||
params = ctx.request.body;
|
||||
_params = ctx.request.body;
|
||||
|
||||
if (!(this.getRole() !== 'admin' && params.uid != this.getUid())) {
|
||||
if (!(this.getRole() !== 'admin' && _params.uid != this.getUid())) {
|
||||
_context12.next = 4;
|
||||
break;
|
||||
}
|
||||
@ -872,7 +878,7 @@ var userController = function (_baseController) {
|
||||
|
||||
case 4:
|
||||
userInst = _yapi2.default.getInst(_user2.default);
|
||||
id = params.uid;
|
||||
id = _params.uid;
|
||||
|
||||
if (id) {
|
||||
_context12.next = 8;
|
||||
@ -888,10 +894,10 @@ var userController = function (_baseController) {
|
||||
};
|
||||
|
||||
if (this.getRole() === 'admin') {
|
||||
params.role && (data.role = params.role);
|
||||
_params.role && (data.role = _params.role);
|
||||
}
|
||||
params.username && (data.username = params.username);
|
||||
params.email && (data.email = params.email);
|
||||
_params.username && (data.username = _params.username);
|
||||
_params.email && (data.email = _params.email);
|
||||
|
||||
if (!data.email) {
|
||||
_context12.next = 18;
|
||||
|
@ -67,6 +67,14 @@ var logModel = function (_baseModel) {
|
||||
add_time: Number
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {String} title log标题
|
||||
* @param {String} content log内容
|
||||
* @param {Enum} type log类型, ['user', 'group', 'interface', 'project', 'other']
|
||||
* @param {Number} uid 用户id
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: 'save',
|
||||
value: function () {
|
||||
|
@ -91,7 +91,7 @@ var userModel = function (_baseModel) {
|
||||
key: 'findByUids',
|
||||
value: function findByUids(uids) {
|
||||
return this.model.find({
|
||||
_id: { $in: [107] }
|
||||
_id: { $in: uids }
|
||||
}).select("_id username email role add_time up_time").exec();
|
||||
}
|
||||
}, {
|
||||
|
@ -155,4 +155,16 @@ exports.filterRes = function (list, rules) {
|
||||
});
|
||||
return filteredRes;
|
||||
});
|
||||
};
|
||||
|
||||
exports.verifyPath = function (path) {
|
||||
if (/^\/[a-zA-Z0-9\-\/_:]+$/.test(path)) {
|
||||
if (path[path.length - 1] === '/') {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
BIN
static/image/footer-bac.jpg
Normal file
BIN
static/image/footer-bac.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 209 KiB |
Loading…
Reference in New Issue
Block a user