Don't wrap changePassword with _catch and persist the password on success.

This commit is contained in:
Edward Lee 2009-09-28 16:28:38 -07:00
parent 6416822a50
commit 21a3b5a172

View File

@ -622,18 +622,26 @@ WeaveSvc.prototype = {
}))(), }))(),
changePassword: function WeaveSvc_changePassword(newpass) changePassword: function WeaveSvc_changePassword(newpass)
this._catch(this._notify("changepwd", "", function() { this._notify("changepwd", "", function() {
let url = this.userAPI + this.username + "/password"; let url = this.userAPI + this.username + "/password";
let res = new Weave.Resource(url); try {
let resp = res.post(newpass); let resp = new Resource(url).post(newpass);
if (resp.status != 200) { if (resp.status != 200) {
this._log.info("Password change failed: " + resp); this._log.debug("Password change failed: " + resp);
throw "Could not change password"; return false;
}
}
catch(ex) {
// Must have failed on some network issue
this._log.debug("changePassword failed: " + Utils.exceptionStr(ex));
return false;
} }
// Save the new password for requests and login manager
this.password = newpass; this.password = newpass;
this.persistLogin();
return true; return true;
}))(), })(),
resetPassphrase: function WeaveSvc_resetPassphrase(newphrase) resetPassphrase: function WeaveSvc_resetPassphrase(newphrase)
this._catch(this._notify("resetpph", "", function() { this._catch(this._notify("resetpph", "", function() {