用户密码规则调整

competitions
杨树明 5 years ago
parent a03bb0dafb
commit 8817c87677

@ -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前缀

@ -153,20 +153,28 @@ class AccountSecure extends Component {
})
}
onPasswordSubmit = () => {
let {basicInfo}=this.props;
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
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 (
<div>
<div className="basicForm settingForm">
@ -426,7 +436,7 @@ class AccountSecure extends Component {
{ updating == PASSWORD &&
<React.Fragment>
<Form.Item
{basicInfo&&basicInfo.has_password===true?<Form.Item
label="旧密码"
className="mb20 formItemInline hideRequireTag"
>
@ -439,7 +449,7 @@ class AccountSecure extends Component {
})(
<Input type="password" placeholder="请设置816位密码区分大小写" autoComplete="new-password"></Input>
)}
</Form.Item>
</Form.Item>:""}
<Form.Item
label="新密码"

Loading…
Cancel
Save