Index: ssts-web/src/main/webapp/systemmanage/adminModifyPWDByExt.js =================================================================== diff -u -r37676 -r40881 --- ssts-web/src/main/webapp/systemmanage/adminModifyPWDByExt.js (.../adminModifyPWDByExt.js) (revision 37676) +++ ssts-web/src/main/webapp/systemmanage/adminModifyPWDByExt.js (.../adminModifyPWDByExt.js) (revision 40881) @@ -1,134 +1,206 @@ +//ZSYY-438:短信验证码 +function sendCodeByModify() { + // Encrypt with the public key... + sendAuthenticationCodeSms(encryptedUserName, function (res) { + if (res.success) { + setCodeTimeoutByModify(); + } + }) +} +var time2 = 60; +//倒计时 +function setCodeTimeoutByModify() { + var button = Ext.getCmp('senCode'); + var t = setTimeout(function () { + if (time2 > 0) { + time2--; + button.setText(time2 + ' s'); + button.setDisabled(true); + setCodeTimeoutByModify(); + } else { + clearTimeout(t); + time2 = 60; + button.setText('发送验证码'); + button.setDisabled(false); + } + }, 1000); +} + function checkSubmit() { - var newPassword = Ext.getCmp('newPassword').getValue(); - var confirmNewPassword = Ext.getCmp('confirmNewPassword').getValue(); - - if (newPassword == ""){ + var newPassword = Ext.getCmp('newPassword').getValue(); + var confirmNewPassword = Ext.getCmp('confirmNewPassword').getValue(); + + if (newPassword == "") { alert("请输入新密码!"); return false; } - var loginUserName = $Id("loginUserName").value; + var loginUserName = $Id("loginUserName").value; //暂时屏蔽验证复杂密码 - var checkPasswordResult = testPasswordReg(newPassword, loginUserName); - if(!checkPasswordResult.success){ - alert(checkPasswordResult.msg); - return false; - } - if (confirmNewPassword == ""){ + var checkPasswordResult = testPasswordReg(newPassword, loginUserName); + if (!checkPasswordResult.success) { + alert(checkPasswordResult.msg); + return false; + } + if (confirmNewPassword == "") { alert('请输入确认新密码!'); return false; } if (newPassword != confirmNewPassword) { - alert("新密码与确认新密码不一致!"); + alert("新密码与确认新密码不一致!"); return false; } return true; } -function changeUserPassword(thiz){ - if(checkSubmit()){ - var newPassword = Ext.getCmp('newPassword').getValue(); - if(isNeedUpdateResetDate=='true'){ - alertTitle = "重置"; - DWREngine.setAsync(false); - UserTableManager.resetPWDAndUpdateResetDate(paramId,newPassword,true,showTable); - DWREngine.setAsync(true); - }else{ - alertTitle = "修改"; - DWREngine.setAsync(false); - UserTableManager.modifyPWD(paramId,newPassword,showTable); - DWREngine.setAsync(true); - } - } - thiz.enable(); - +function changeUserPassword(thiz) { + if (checkSubmit()) { + var newPassword = Ext.getCmp('newPassword').getValue(); + if (isNeedUpdateResetDate == 'true') { + alertTitle = "重置"; + DWREngine.setAsync(false); + UserTableManager.resetPWDAndUpdateResetDate(paramId, newPassword, true, showTable); + DWREngine.setAsync(true); + } else { + alertTitle = "修改"; + DWREngine.setAsync(false); + UserTableManager.modifyPWD(paramId, newPassword, showTable); + DWREngine.setAsync(true); + } + } + thiz.enable(); + } function showTable(table) { - if(table){ - alert(alertTitle+"密码成功!"); - window.close(); - }else{ - alert(alertTitle+"密码失败,请稍候再试!"); - } + if (table) { + alert(alertTitle + "密码成功!"); + window.close(); + } else { + alert(alertTitle + "密码失败,请稍候再试!"); + } } -function showUserName(userName){ - Ext.getCmp('userName').setValue(userName.split(',')[0]); - Ext.getCmp('loginUserName').setValue(userName.split(',')[1]); +function showUserName(userName) { + Ext.getCmp('userName').setValue(userName.split(',')[0]); + Ext.getCmp('loginUserName').setValue(userName.split(',')[1]); } - + var formObj; -Ext.onReady(function(){ +Ext.onReady(function () { Ext.QuickTips.init(); //ZSRY-72:增加密码设置要求提示语 - var msg = getModifyPwdMsg(); + var msg = getModifyPwdMsg(); formObj = new Ext.FormPanel({ - frame:true, - labelWidth:70, - height:210, - bodyStyle:'padding:5px 10px 0px 10px', + frame: true, + labelWidth: 70, + height: 230, + bodyStyle: 'padding:5px 10px 0px 10px', items: [{ - xtype:'fieldset', + xtype: 'fieldset', title: '密码修改', - height:140, + height: 160, id: 'regionSet', - items :[{ - xtype:'textfield', - fieldLabel :'用户姓名', - id :'userName', - name :'userName', - readOnly : true, - cls:'fieldReadOnlyNoRemove' - },{ - xtype:'hidden', - id :'loginUserName', - name :'loginUserName' - },{ - xtype:'textfield', - fieldLabel :'新密码', - id :'newPassword', - name :'newPassword', + items: [{ + xtype: 'textfield', + fieldLabel: '用户姓名', + id: 'userName', + name: 'userName', + readOnly: true, + cls: 'fieldReadOnlyNoRemove' + }, { + xtype: 'hidden', + id: 'loginUserName', + name: 'loginUserName' + }, { + xtype: 'textfield', + fieldLabel: '新密码', + id: 'newPassword', + name: 'newPassword', width: 200, - inputType:"password" - },{ - xtype:'textfield', - fieldLabel :'确认密码', - id :'confirmNewPassword', - name :'confirmNewPassword', + inputType: "password" + }, { + xtype: 'textfield', + fieldLabel: '确认密码', + id: 'confirmNewPassword', + name: 'confirmNewPassword', width: 200, - inputType:"password" - }, { - items:[{ - hidden:msg == ''?true:false, - layout:'column', - items:[{ - id:'showPwdMessage', - xtype:'textarea', - width : 320, - allowBlank : true, - labelSeparator:'', - labelWidth:0, + inputType: "password" + }, { + hidden: msg == '' ? true : false, + layout: 'column', + items: [{ + layout: 'form', + columnWidth: .75, + items: [{ + xtype: 'textfield', + fieldLabel: '验证码', + name: 'verificationCode', + id: 'verificationCode', + width: 170, + msgTarget: 'side', + allowBlank: true + }] + }, { + layout: 'form', + columnWidth: .25, + items: [{ + id: 'senCode', + xtype: 'button', + text: '发送验证码', + disabled: false, + handler: function () { + sendCodeByModify(); + } + }] + }] + }, { + items: [{ + hidden: msg == '' ? true : false, + layout: 'column', + items: [{ + id: 'showPwdMessage', + xtype: 'textarea', + width: 320, + allowBlank: true, + labelSeparator: '', + labelWidth: 0, anchor: '99%', - readOnly : true, - cls : 'fieldReadOnlyNoRemove', + readOnly: true, + cls: 'fieldReadOnlyNoRemove', value: msg }] }] }] }], buttons: [{ text: '确定', - handler: function (){ - this.disable(); - changeUserPassword(this); + handler: function () { + var that = this; + if (sstsConfig.needBeStrongPwdWhenModifyPwd && sstsConfig.enableTwoFactorAuthentication) { + if (checkSubmit()) { + var verificationCode = Ext.getCmp('verificationCode').getValue(); + var encryptedUserCode = encrypt.encrypt(verificationCode); + validateAuthenticationCode(encryptedUserName, encryptedUserCode, function (res) { + if (res.success) { + that.disable(); + changeUserPassword(that); + } else { + showResult(res.message); + } + }) + } + } else { + that.disable(); + changeUserPassword(that); + } } - },{ + }, { text: '取消', - handler:function(){ + handler: function () { window.close(); } }] @@ -137,7 +209,7 @@ formObj.render("formDiv"); initGetUserNameById(); Ext.getCmp('newPassword').focus(); - if(msg !== ''){ - Ext.getCmp('showPwdMessage').el.dom.style.color = 'red'; - } + if (msg !== '') { + Ext.getCmp('showPwdMessage').el.dom.style.color = 'red'; + } });