Change Password widget update button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2018 02:49 PM
Hello all,
I am using the "change password " widget in one of my portals. The widget worked fine before but now after I enter all my information and click "update", nothing happens. I made a copy of the widget so I did not alter the original out of the box widget. I tried the unaltered out of the box widget after the copy of the widget stopped functioning, the out of the box widget is also not functioning.
I am not sure what went wrong over the weekend, the widget is not functioning.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2018 04:44 PM
Hi,
Oddly, this isn't one of those "core" widgets that isn't able to be altered without cloning...so while you went back to the "unaltered" widget...there's a high chance you may have accidentally changed this some. To assist and for the sake of "troubleshooting"...I'll post my widget code and you can copy and paste this back in to your unaltered widget to "reset" it so to speak:
HTML:
<div class="panel panel-{{::options.color}} b">
<div class="panel-heading">
<h4 class="panel-title">
<i ng-if="options.glyph" class="fa fa-{{options.glyph}} m-r"></i>
${Change My Password}
</h4>
</div>
<div class="panel-body">
<div ng-hide="c.changeSuccess">
<label class="field-label" for="current_password">{{::data.currentPasswordMsg}}</label>
<div class="m-b-sm">
<input class="form-control" type="password" ng-model="c.current_password"
ng-required="true" id="current_password" name="current_password" />
</div>
<label class="field-label" for="new_password">{{::data.newPasswordMsg}}</label>
<div class="m-b-sm">
<input class="form-control" type="password" ng-model="c.new_password"
ng-required="true" id="new_password" name="new_password" />
</div>
<label class="field-label" for="confirm_password">{{::data.confirmPasswordMsg}}</label>
<div class="m-b-sm">
<input class="form-control" type="password" ng-model="c.confirm_password"
ng-required="true" id="confirm_password" name="confirm_password" password-match />
</div>
</div>
<div class="m-b-sm pwd-hint" role="alert" ng-show="c.errorMessage() || c.resultMessage">
<span class="text-danger">{{c.errorMessage()}}</span>
<span class="text-primary" ng-class="{'text-danger': c.error}" ng-bind-html="c.resultMessage"></span>
</div>
<div class="m-b-xl">
<button type="submit" ng-hide="c.changeSuccess" class="btn btn-primary pull-right m-b-lg m-t-sm"
ng-disabled="c.disableUpdate()" id="update" name="update"
ng-click="c.action()">${Update}</button>
</div>
</div>
CSS:
.panel-heading {
padding: 20px 30px 7px;
}
.panel-body {
padding: 20px 30px 10px 30px;
}
.pwd-hint p,
.pwd-hint div {
margin: 0;
}
Client Script:
function($scope, $window, $http, spUtil, $rootScope, $timeout, spAriaUtil) {
var c = this;
c.action = function(){
c.resultMessage = '';
$.ajax({
url : 'xmlhttp.do',
data : {
sysparm_processor : 'PwdAjaxWFRequestProcessor',
sysparm_name : 'validatePassword',
sysparam_process_id : c.data.procId,
sysparam_new_password : c.new_password
},
headers : {
'X-UserToken' : g_ck
},
success : setPassword,
error: function(){ }
});
};
c.disableUpdate = function(){
return !(c.current_password && c.new_password && c.confirm_password) || c.errorMessage();
};
c.errorMessage = function(){
if((c.current_password && c.new_password) && (c.current_password == c.new_password)){
c.resultMessage = '';
return c.data.reusedPasswordMsg;
}
else if((c.new_password && c.confirm_password) && (c.new_password != c.confirm_password)){
c.resultMessage = '';
return c.data.notMatchMsg;
}
else return '';
};
function setPassword(response) {
var xml = response.documentElement.outerHTML;
var success = /answer=['"]success['"]/.test(xml);
if(success) {
c.data.action = 'update';
c.data.old_password = c.current_password;
c.data.new_password = c.new_password;
c.server.update().then(function() {
c.error = false;
if(c.data.result == 'success'){
c.resultMessage = c.data.successMsg;
c.changeSuccess = true;
}
else {
c.error = true;
if (c.data.result == 'incorrect old password')
c.resultMessage = c.data.wrongPasswordMsg;
else if (c.data.result == 'weak password')
c.resultMessage = c.data.complexityMsg;
else
c.resultMessage = c.data.result;
}
});
}
else {
c.error = true;
c.resultMessage = c.data.complexityMsg;
}
}
}
Server Script:
(function(data) {
var user_id = gs.getUser().getID();
data.procId = gs.getProperty('glide.service_portal.default_password_process', 'c6b0c20667100200a5a0f3b457415ad5');
data.password_hint = getPasswordHint(data.procId);
if (input && input.action === 'update') {
var enc = new GlideEncrypter();
var encypted_new_passwd = enc.encrypt(input.new_password);
var encypted_old_passwd = enc.encrypt(input.old_password);
var process = new SNC.PwdProcess(data.procId);
var processSysId = process.getId();
var trackingMgr = new SNC.PwdTrackingManager();
var requestId = trackingMgr.createRequest(processSysId, user_id, gs.getSessionID(), 3);// 3: request type for Change Password
trackingMgr.updateRequestActionType(requestId, 4);// 4: request action type for Change Password
var wf = new Workflow();
var workflowId = wf.getWorkflowFromName('Pwd Change - Master');
var gr = wf.startFlow(workflowId, null, 'update', {
u_request_id : requestId,
u_user_id : user_id,
u_new_password : encypted_new_passwd,
u_old_password : encypted_old_passwd
});
gr.next();
var ctxId = gr.getValue('sys_id');
// check password changed or not
var wf_gr = new GlideRecord('wf_context');
if (wf_gr.get(ctxId)) {
data.result = wf_gr.getValue('result');
data.state = wf_gr.getValue('state');
}
}
data.newPasswordMsg = gs.getMessage("New Password");
data.currentPasswordMsg = gs.getMessage("Current Password");
data.confirmPasswordMsg = gs.getMessage("Confirm Password");
data.complexityMsg = gs.getMessage("Invalid password: " + data.password_hint);
data.successMsg = gs.getMessage('Your password has been changed successfully!');
data.wrongPasswordMsg = gs.getMessage('The old password you provided does not match our records.');
data.reusedPasswordMsg = gs.getMessage('New password cannot be same as your current password.');
data.notMatchMsg = gs.getMessage('Passwords must match.');
function getPasswordHint(procId) {
var credMgr = new SNC.PwdCredentialStoreManager();
var credId = credMgr.getCredentialStoreIdByProcessId(procId);
var credGr = new GlideRecord('pwd_cred_store');
if (credGr.get(credId)) {
return credGr.pwd_rule_hint;
}
}
})(data);
Let's see what happens with this, then we can move forward.
Please mark reply as Helpful/Correct, if applicable.
Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2018 11:16 AM
Hello Allen,
I checked the code you sent me, line by line and everything matches up. The widget works in my instance but I am on a client instance and the widget does not seem to work there. I created a portal for this client, I believe the issue is the portal. If I place the widget in another portal on a blank page, in the same instance, it works. The portal I created for the client includes a variety of out of the box widgets and custom widgets. There may be compatibility issues?
If you could think of anything else, please let me know.
Thank you,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2020 07:20 AM
Hi
Did you figure this out? I am facing the same issue.