Skip to content
Permalink
Browse files

Bug 1296328 - Update FxA device registration on password change. r=markh

  • Loading branch information
philbooth committed Aug 19, 2016
1 parent 622e92b commit b1bab4c5a0ffbf617ffbff965c503694626b864c
@@ -341,7 +341,8 @@ this.FxAccountsWebChannelHelpers.prototype = {
log.info("changePassword ignoring unsupported field", name);
}
}
return this._fxAccounts.updateUserAccountData(newCredentials);
return this._fxAccounts.updateUserAccountData(newCredentials)
.then(() => this._fxAccounts.updateDeviceRegistration());
},

/**
@@ -403,7 +403,10 @@ add_test(function test_helpers_open_sync_preferences() {
});

add_task(function* test_helpers_change_password() {
let updateCalled = false;
let wasCalled = {
updateUserAccountData: false,
updateDeviceRegistration: false
};
let helpers = new FxAccountsWebChannelHelpers({
fxAccounts: {
updateUserAccountData(credentials) {
@@ -413,15 +416,49 @@ add_task(function* test_helpers_change_password() {
do_check_true(credentials.hasOwnProperty("kA"));
// "foo" isn't a field known by storage, so should be dropped.
do_check_false(credentials.hasOwnProperty("foo"));
updateCalled = true;
wasCalled.updateUserAccountData = true;

resolve();
});
},

updateDeviceRegistration() {
do_check_eq(arguments.length, 0);
wasCalled.updateDeviceRegistration = true;
return Promise.resolve()
}
}
});
yield helpers.changePassword({ email: "email", uid: "uid", kA: "kA", foo: "foo" });
do_check_true(updateCalled);
do_check_true(wasCalled.updateUserAccountData);
do_check_true(wasCalled.updateDeviceRegistration);
});

add_task(function* test_helpers_change_password_with_error() {
let wasCalled = {
updateUserAccountData: false,
updateDeviceRegistration: false
};
let helpers = new FxAccountsWebChannelHelpers({
fxAccounts: {
updateUserAccountData() {
wasCalled.updateUserAccountData = true;
return Promise.reject();
},

updateDeviceRegistration() {
wasCalled.updateDeviceRegistration = true;
return Promise.resolve()
}
}
});
try {
yield helpers.changePassword({});
do_check_false('changePassword should have rejected');
} catch (_) {
do_check_true(wasCalled.updateUserAccountData);
do_check_false(wasCalled.updateDeviceRegistration);
}
});

function run_test() {

0 comments on commit b1bab4c

Please sign in to comment.
You can’t perform that action at this time.