06-24-2015 08:43 AM
/**
* User Profile Change Password Update method
*
* @method POST
*/
function main()
{
var oldpass = args.oldpassword;
var newpass1 = args.newpassword;
logger.log("here");
// ensure we have valid values and that the new passwords match
// perform the REST API to change the user password
var params = new Array(2);
params["oldpw"] = oldpass;
params["newpw"] = newpass1;
var connector = remote.connect("alfresco");
var result = connector.post(
"/api/person/changepassword/" + args.username,
jsonUtils.toJSONString(params),
"application/json");
if (result.status.code == 401)
{
model.success = false;
if (result.status.message != "")
{
model.errormsg = result.status.message;
}
else
{
// The proxy has eaten the message
// This is caused by some SSO compatibility code somewhere…
model.errormsg = msg.get("message.passwordchangeauthfailed");
}
}
else
{
var repoJSON = JSON.parse(result);
if (repoJSON.success !== undefined)
{
model.success = repoJSON.success;
}
else
{
model.success = false;
model.errormsg = repoJSON.message;
}
}
}
main();
<webscript>
<shortname>Change Password POST</shortname>
<description>Change user password POST form submission processing</description>
<format default="json" />
<url>/components/profile/ChangePasswordPostWebscript</url>
<arg>
<shortname>username</shortname>
</arg>
<arg>
<shortname>oldpassword</shortname>
</arg>
<arg>
<shortname>newpassword</shortname>
</arg>
<arg>
<shortname>alf_ticket</shortname>
</arg>
<authentication>user</authentication>
</webscript>
07-01-2015 10:54 AM
07-01-2015 11:31 AM
07-03-2015 10:29 AM
var passwordObj =
{
newpw: "newpass"
};
passwordObj.oldpw= "oldpass";
var updatepasswordurl = cotextPath + "service/api/person/changepassword/" + encodeURIComponent("username")+"?alf_ticket="+ticket;
Alfresco.util.Ajax.request({
url: updatepasswordurl,
method: Alfresco.util.Ajax.POST,
requestContentType: Alfresco.util.Ajax.JSON,
dataObj: passwordObj,
successCallback:{
fn: function(response){
},
scope:this
},
failureCallback:{
fn: function(response){
Alfresco.util.PopupManager.displayPrompt(
{
text: response.serverResponse.responseText
});
},
scope:this
}
});
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.