From 8817c87677bc43155a0dce5f735daa0de2bd1f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 12 Oct 2019 16:45:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=AF=86=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E5=88=99=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 24 +++++++++---------- .../src/modules/user/account/AccountSecure.js | 24 +++++++++++++------ 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 98571d818..c00c5fb62 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -21,16 +21,16 @@ let hashTimeout // TODO 开发期多个身份切换 let debugType ="" -// if (isDev) { -// const _search = window.location.search; -// let parsed = {}; -// if (_search) { -// parsed = queryString.parse(_search); -// } -// debugType = window.location.search.indexOf('debug=t') != -1 ? 'teacher' : -// window.location.search.indexOf('debug=s') != -1 ? 'student' : -// window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin' -// } +if (isDev) { + const _search = window.location.search; + let parsed = {}; + if (_search) { + parsed = queryString.parse(_search); + } + debugType = window.location.search.indexOf('debug=t') != -1 ? 'teacher' : + window.location.search.indexOf('debug=s') != -1 ? 'student' : + window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin' +} window._debugType = debugType; export function initAxiosInterceptors(props) { initOnlineOfflineListener() @@ -84,9 +84,9 @@ export function initAxiosInterceptors(props) { } config.url = `${proxy}${url}`; if (config.url.indexOf('?') == -1) { - config.url = `${config.url}?debug=${debugType}`; + config.url = `${config.url}?debug=${'student'}`; } else { - config.url = `${config.url}&debug=${debugType}`; + config.url = `${config.url}&debug=${'student'}`; } } else { // 加api前缀 diff --git a/public/react/src/modules/user/account/AccountSecure.js b/public/react/src/modules/user/account/AccountSecure.js index 797b350d2..2e90824c9 100644 --- a/public/react/src/modules/user/account/AccountSecure.js +++ b/public/react/src/modules/user/account/AccountSecure.js @@ -153,20 +153,28 @@ class AccountSecure extends Component { }) } onPasswordSubmit = () => { + let {basicInfo}=this.props; this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { - if(values.p_old == values.p_new){ - this.props.showNotification("新密码不能与旧密码相同!"); - return; - } + if(basicInfo&&basicInfo.has_password===true){ + if(values.p_old == values.p_new){ + this.props.showNotification("新密码不能与旧密码相同!"); + return; + } + } + if(values.p_again != values.p_new){ this.props.showNotification("两次输入的新密码必须一致!"); return; } let {login}=this.props.current_user; let url=`/users/accounts/${login}/password.json`; + let p_old=undefined; + if(basicInfo&&basicInfo.has_password===true){ + p_old=values.p_old + } axios.put((url),{ - old_password:values.p_old, + old_password:p_old, password:values.p_new }).then((result)=>{ if(result){ @@ -215,6 +223,8 @@ class AccountSecure extends Component { let {basicInfo}=this.props; const { getFieldDecorator } = this.props.form; const { updating,seconds,secondsFlag } = this.state + + console.log(basicInfo&&basicInfo.has_password) return (