зеркало из https://github.com/mozilla/gecko-dev.git
WeaveSvc_createAccount: async + async/yield -> sync. Fix chrome to call its onComplete with the return of createAccount.
This commit is contained in:
Родитель
846544495d
Коммит
3007254399
|
@ -573,16 +573,12 @@ WeaveSvc.prototype = {
|
|||
Svc.Observer.notifyObservers(null, "weave:service:logout:finish", "");
|
||||
},
|
||||
|
||||
createAccount: function WeaveSvc_createAccount(onComplete, username, password, email,
|
||||
createAccount: function WeaveSvc_createAccount(username, password, email,
|
||||
captchaChallenge, captchaResponse) {
|
||||
let fn = function WeaveSvc__createAccount() {
|
||||
let self = yield;
|
||||
|
||||
function enc(x) encodeURIComponent(x);
|
||||
let message = "uid=" + enc(username) + "&password=" + enc(password) +
|
||||
"&mail=" + enc(email) +
|
||||
"&recaptcha_challenge_field=" + enc(captchaChallenge) +
|
||||
"&recaptcha_response_field=" + enc(captchaResponse);
|
||||
"&mail=" + enc(email) + "&recaptcha_challenge_field=" +
|
||||
enc(captchaChallenge) + "&recaptcha_response_field=" + enc(captchaResponse);
|
||||
|
||||
let url = Svc.Prefs.get('tmpServerURL') + '0.3/api/register/new';
|
||||
let res = new Weave.Resource(url);
|
||||
|
@ -593,9 +589,10 @@ WeaveSvc.prototype = {
|
|||
// fixme: Resource throws on error - it really shouldn't :-/
|
||||
let resp;
|
||||
try {
|
||||
resp = yield res.post(self.cb, message);
|
||||
} catch (e) {
|
||||
this._log.trace("Create account error: " + e);
|
||||
resp = res.post(message);
|
||||
}
|
||||
catch(ex) {
|
||||
this._log.trace("Create account error: " + ex);
|
||||
}
|
||||
|
||||
if (res.lastChannel.responseStatus != 200 &&
|
||||
|
@ -606,9 +603,7 @@ WeaveSvc.prototype = {
|
|||
else
|
||||
this._log.info("Account created: " + resp);
|
||||
|
||||
self.done(res.lastChannel.responseStatus);
|
||||
};
|
||||
fn.async(this, onComplete);
|
||||
return res.lastChannel.responseStatus;
|
||||
},
|
||||
|
||||
// stuff we need to to after login, before we can really do
|
||||
|
|
Загрузка…
Ссылка в новой задаче