Merge pull request #542 from jasonjoo2010/login

opti: hide register form when closeRegister is true and fix importing har content base64 problem
This commit is contained in:
sean1025 2018-11-01 11:16:52 +08:00 committed by GitHub
commit dbd105864e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 47 additions and 11 deletions

View File

@ -21,7 +21,8 @@ const changeHeight = {
state => {
return {
loginData: state.user,
isLDAP: state.user.isLDAP
isLDAP: state.user.isLDAP,
canRegister: state.user.canRegister
};
},
{
@ -43,7 +44,8 @@ class Login extends Component {
history: PropTypes.object,
loginActions: PropTypes.func,
loginLdapActions: PropTypes.func,
isLDAP: PropTypes.bool
isLDAP: PropTypes.bool,
canRegister: PropTypes.bool
};
handleSubmit = e => {
@ -79,7 +81,7 @@ class Login extends Component {
};
render() {
const { getFieldDecorator } = this.props.form;
const { getFieldDecorator, canRegister } = this.props.form;
const { isLDAP } = this.props;
const emailRule =
@ -97,7 +99,7 @@ class Login extends Component {
<FormItem>
<RadioGroup defaultValue="ldap" onChange={this.handleFormLayoutChange}>
<Radio value="ldap">LDAP</Radio>
<Radio value="normal">普通登录</Radio>
<Radio value="normal" disabled={!canRegister}>普通登录</Radio>
</RadioGroup>
</FormItem>
)}

View File

@ -8,7 +8,8 @@ import './Login.scss';
const TabPane = Tabs.TabPane;
@connect(state => ({
loginWrapActiveKey: state.user.loginWrapActiveKey
loginWrapActiveKey: state.user.loginWrapActiveKey,
canRegister: state.canRegister
}))
export default class LoginWrap extends Component {
constructor(props) {
@ -17,11 +18,16 @@ export default class LoginWrap extends Component {
static propTypes = {
form: PropTypes.object,
loginWrapActiveKey: PropTypes.string
loginWrapActiveKey: PropTypes.string,
canRegister: PropTypes.bool
};
render() {
const { loginWrapActiveKey } = this.props;
const { loginWrapActiveKey, canRegister } = this.props;
{/** show only login when register is disabled */}
if (!canRegister) {
return (<LoginForm />);
}
return (
<Tabs
defaultActiveKey={loginWrapActiveKey}

View File

@ -18,6 +18,7 @@ const MEMBER_STATUS = 2;
// Reducer user
const initialState = {
isLogin: false,
canRegister: true,
isLDAP: false,
userName: null,
uid: null,
@ -45,6 +46,7 @@ export default (state = initialState, action) => {
...state,
isLogin: action.payload.data.errcode == 0,
isLDAP: action.payload.data.ladp,
canRegister: action.payload.data.canRegister,
role: action.payload.data.data ? action.payload.data.data.role : null,
loginState: action.payload.data.errcode == 0 ? MEMBER_STATUS : GUEST_STATUS,
userName: action.payload.data.data ? action.payload.data.data.username : null,

View File

@ -1,5 +1,6 @@
const Mock = require('mockjs');
const filter = require('./power-string.js').filter;
const stringUtils = require('./power-string.js').utils;
const json5 = require('json5');
const Ajv = require('ajv');
/**
@ -168,6 +169,14 @@ function isJson(json) {
exports.isJson = isJson;
exports.unbase64 = function(base64Str) {
try {
return stringUtils.unbase64(base64Str);
} catch (err) {
return base64Str;
}
};
exports.json_parse = function(json) {
try {
return JSON.parse(json);

View File

@ -1,7 +1,7 @@
import { message } from 'antd';
import URL from 'url';
const GenerateSchema = require('generate-schema/src/schemas/json.js');
import { json_parse } from '../../common/utils.js';
import { json_parse, unbase64 } from '../../common/utils.js';
const transformJsonToSchema = json => {
json = json || {};
@ -199,7 +199,12 @@ function postman(importDataModule) {
res[item] = 'json';
} else if (item === 'res_body') {
res.res_body_is_json_schema = true;
res[item] = transformJsonToSchema(data.response.content.text);
if (data.response.content.encoding && data.response.content.encoding == 'base64') {
//base64
res[item] = transformJsonToSchema(unbase64(data.response.content.text));
} else {
res[item] = transformJsonToSchema(data.response.content.text);
}
} else {
res[item] = data.request[reflect[item]];
}

View File

@ -118,6 +118,15 @@ class baseController {
return false;
}
}
async checkRegister() {
// console.log('config', yapi.WEBCONFIG);
if (yapi.WEBCONFIG.closeRegister) {
return false;
} else {
return true;
}
}
async checkLDAP() {
// console.log('config', yapi.WEBCONFIG);
@ -151,6 +160,7 @@ class baseController {
}
body.ladp = await this.checkLDAP();
body.canRegister = await this.checkRegister();
ctx.body = body;
}

View File

@ -1 +1 @@
window.WEBPACK_ASSETS = {"index.js":{"js":"index@81ab5d398510e17a91f0.js","css":"index@81ab5d398510e17a91f0.css"},"lib":{"js":"lib@85660194fef2283b4245.js"},"lib2":{"js":"lib2@b41e63d1ac00768540fd.js"},"lib3":{"js":"lib3@c4e2776af9680319a3d7.js"},"manifest":{"js":"manifest@f2f4bd774d6c221b3d5f.js"}}

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.