ResetPwdUI.js
4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/**
* Project : AMDA-NG
* Name : ResetPwdUI.js
* @plugin amdaUI.ResetPwdUI
* @extends Ext.panel.Panel
* @brief Reset password view
* @author Benjamin
* @version $Id: ResetPwdUI.js 2031 2024-09-19 11:28:34Z benjamin $
*/
Ext.define('amdaUI.ResetPwdUI', {
extend: 'Ext.form.Panel',
alias: 'widget.panelResetPwd',
constructor: function(config) {
this.init(config);
this.callParent(arguments);
},
getInfoMsg : function()
{
return '' +
'To make the change, type your current password in the appropriate box, followed by a new one, which you will then confirm.<br>'+
'Please note that passwords are encrypted in our database and we are unable to retrieve them for you.<br>'+
'If you have any problems, please contact the CDPP/AMDA team.';
},
getUser : function()
{
return sessionID;
},
onSendFinish : function(result, e){
var t = e.getTransaction();
if (e.status)
{
if (result && result.success)
{
// SUCCESS
var win = myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.resetpwd.id);
Ext.MessageBox.show({
title: 'New password set successfully',
msg: 'For your next AMDA session, you will need to enter your new password',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.INFO,
fn: function (btn){
win.close();
}
});
return;
}
//ERROR
var msgErr = 'Unknown error';
if (result.message)
{
msgErr = result.message;
}
Ext.Msg.show({title:'Error', msg: msgErr, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
}
else
{
// FAILURE
Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
}
},
onResetPwd : function(b,e){
//get links to components
var fieldset = this.getComponent('resetpwd_fieldset');
var crtPwd = fieldset.getComponent('crtpwd_field');
var newPwd = fieldset.getComponent('newpwd_field');
var newPwd2 = fieldset.getComponent('newpwd2_field');
if (!crtPwd.isValid() && !newPwd.isValid() || !newPwd2.isValid())
{
Ext.Msg.show({title:'Error', msg: 'Some field values are invalid', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
return;
}
if (newPwd.getValue() != newPwd2.getValue()) {
Ext.Msg.show({title: 'Error', msg: 'Password does not match Confirmation', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
return;
}
//make the object to send
var reset = {
crtpwd : crtPwd.getValue(),
newpwd : newPwd.getValue()
};
//call action
AmdaAction.resetPwd(reset,this.onSendFinish,this);
},
init : function(config)
{
var myConf = {
layout: 'fit',
bodyStyle: { background: '#ddecfe'},
items : [{
xtype: 'fieldset',
itemId: 'resetpwd_fieldset',
layout: 'anchor',
anchor: '100%',
items : [
{
xtype: 'displayfield',
name: 'information',
height : 80,
fieldLabel: '',
anchor: '100%',
value: this.getInfoMsg()
},
{
xtype: 'textfield',
itemId: 'crtpwd_field',
anchor: '100%',
name: 'crtpwd',
fieldLabel: 'Current Password',
inputType: 'password',
allowBlank: false,
regex: /^[a-zA-Z0-9./]+$/,
regexText: 'Only alphanumeric, . and / characters allowed'
},
{
xtype: 'textfield',
itemId: 'newpwd_field',
anchor: '100%',
name: 'newpwd',
fieldLabel: 'New Password',
inputType: 'password',
allowBlank: false,
regex: /^[a-zA-Z0-9./]+$/,
regexText: 'Only alphanumeric, . and / characters allowed',
minLength: 4,
maxLength: 20
},
{
xtype: 'textfield',
itemId: 'newpwd2_field',
anchor: '100%',
name: 'newpwd2',
fieldLabel: 'Confirm New Password',
inputType: 'password',
allowBlank: false,
regex: /^[a-zA-Z0-9./]+$/,
regexText: 'Only alphanumeric, . and / characters allowed',
minLength: 4,
maxLength: 20
}
]
}],
dockedItems: [{
xtype: 'toolbar',
dock: 'bottom',
items: [
'->',
{
iconCls: 'icon-resetpwd',
text: 'Reset',
scope: this,
tooltip: 'Reset password',
handler: this.onResetPwd
}
]
}]
}
Ext.apply (this , Ext.apply (arguments, myConf));
}
});