用户密码规则调整

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

@ -21,16 +21,16 @@ let hashTimeout
// TODO 开发期多个身份切换 // TODO 开发期多个身份切换
let debugType ="" let debugType =""
// if (isDev) { if (isDev) {
// const _search = window.location.search; const _search = window.location.search;
// let parsed = {}; let parsed = {};
// if (_search) { if (_search) {
// parsed = queryString.parse(_search); parsed = queryString.parse(_search);
// } }
// debugType = window.location.search.indexOf('debug=t') != -1 ? 'teacher' : debugType = window.location.search.indexOf('debug=t') != -1 ? 'teacher' :
// window.location.search.indexOf('debug=s') != -1 ? 'student' : window.location.search.indexOf('debug=s') != -1 ? 'student' :
// window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin' window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin'
// } }
window._debugType = debugType; window._debugType = debugType;
export function initAxiosInterceptors(props) { export function initAxiosInterceptors(props) {
initOnlineOfflineListener() initOnlineOfflineListener()
@ -84,9 +84,9 @@ export function initAxiosInterceptors(props) {
} }
config.url = `${proxy}${url}`; config.url = `${proxy}${url}`;
if (config.url.indexOf('?') == -1) { if (config.url.indexOf('?') == -1) {
config.url = `${config.url}?debug=${debugType}`; config.url = `${config.url}?debug=${'student'}`;
} else { } else {
config.url = `${config.url}&debug=${debugType}`; config.url = `${config.url}&debug=${'student'}`;
} }
} else { } else {
// 加api前缀 // 加api前缀

@ -153,20 +153,28 @@ class AccountSecure extends Component {
}) })
} }
onPasswordSubmit = () => { onPasswordSubmit = () => {
let {basicInfo}=this.props;
this.props.form.validateFieldsAndScroll((err, values) => { this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) { if (!err) {
if(values.p_old == values.p_new){ if(basicInfo&&basicInfo.has_password===true){
this.props.showNotification("新密码不能与旧密码相同!"); if(values.p_old == values.p_new){
return; this.props.showNotification("新密码不能与旧密码相同!");
} return;
}
}
if(values.p_again != values.p_new){ if(values.p_again != values.p_new){
this.props.showNotification("两次输入的新密码必须一致!"); this.props.showNotification("两次输入的新密码必须一致!");
return; return;
} }
let {login}=this.props.current_user; let {login}=this.props.current_user;
let url=`/users/accounts/${login}/password.json`; 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),{ axios.put((url),{
old_password:values.p_old, old_password:p_old,
password:values.p_new password:values.p_new
}).then((result)=>{ }).then((result)=>{
if(result){ if(result){
@ -215,6 +223,8 @@ class AccountSecure extends Component {
let {basicInfo}=this.props; let {basicInfo}=this.props;
const { getFieldDecorator } = this.props.form; const { getFieldDecorator } = this.props.form;
const { updating,seconds,secondsFlag } = this.state const { updating,seconds,secondsFlag } = this.state
console.log(basicInfo&&basicInfo.has_password)
return ( return (
<div> <div>
<div className="basicForm settingForm"> <div className="basicForm settingForm">
@ -426,7 +436,7 @@ class AccountSecure extends Component {
{ updating == PASSWORD && { updating == PASSWORD &&
<React.Fragment> <React.Fragment>
<Form.Item {basicInfo&&basicInfo.has_password===true?<Form.Item
label="旧密码" label="旧密码"
className="mb20 formItemInline hideRequireTag" className="mb20 formItemInline hideRequireTag"
> >
@ -439,7 +449,7 @@ class AccountSecure extends Component {
})( })(
<Input type="password" placeholder="请设置816位密码区分大小写" autoComplete="new-password"></Input> <Input type="password" placeholder="请设置816位密码区分大小写" autoComplete="new-password"></Input>
)} )}
</Form.Item> </Form.Item>:""}
<Form.Item <Form.Item
label="新密码" label="新密码"

Loading…
Cancel
Save