mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 983445 - Verification causes logout on device. r=jedp
This commit is contained in:
parent
7d44cfb133
commit
b168828c29
@ -505,27 +505,31 @@ FxAccountsInternal.prototype = {
|
||||
*/
|
||||
getKeys: function() {
|
||||
let currentState = this.currentAccountState;
|
||||
return currentState.getUserAccountData().then((data) => {
|
||||
if (!data) {
|
||||
return currentState.getUserAccountData().then((userData) => {
|
||||
if (!userData) {
|
||||
throw new Error("Can't get keys; User is not signed in");
|
||||
}
|
||||
if (data.kA && data.kB) {
|
||||
return data;
|
||||
if (userData.kA && userData.kB) {
|
||||
return userData;
|
||||
}
|
||||
if (!currentState.whenKeysReadyDeferred) {
|
||||
currentState.whenKeysReadyDeferred = Promise.defer();
|
||||
this.fetchAndUnwrapKeys(data.keyFetchToken).then(
|
||||
data => {
|
||||
if (!data.kA || !data.kB) {
|
||||
currentState.whenKeysReadyDeferred.reject(
|
||||
new Error("user data missing kA or kB")
|
||||
);
|
||||
return;
|
||||
if (userData.keyFetchToken) {
|
||||
this.fetchAndUnwrapKeys(userData.keyFetchToken).then(
|
||||
(dataWithKeys) => {
|
||||
if (!dataWithKeys.kA || !dataWithKeys.kB) {
|
||||
currentState.whenKeysReadyDeferred.reject(
|
||||
new Error("user data missing kA or kB")
|
||||
);
|
||||
return;
|
||||
}
|
||||
currentState.whenKeysReadyDeferred.resolve(dataWithKeys);
|
||||
},
|
||||
(err) => {
|
||||
currentState.whenKeysReadyDeferred.reject(err);
|
||||
}
|
||||
currentState.whenKeysReadyDeferred.resolve(data);
|
||||
},
|
||||
err => currentState.whenKeysReadyDeferred.reject(err)
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
return currentState.whenKeysReadyDeferred.promise;
|
||||
}).then(result => currentState.resolve(result));
|
||||
@ -537,6 +541,7 @@ FxAccountsInternal.prototype = {
|
||||
return Task.spawn(function* task() {
|
||||
// Sign out if we don't have a key fetch token.
|
||||
if (!keyFetchToken) {
|
||||
log.warn("improper fetchAndUnwrapKeys() call: token missing");
|
||||
yield this.signOut();
|
||||
return null;
|
||||
}
|
||||
|
@ -305,8 +305,8 @@ add_test(function test_getKeys() {
|
||||
});
|
||||
});
|
||||
|
||||
// getKeys with no keyFetchToken should trigger signOut
|
||||
add_test(function test_getKeys_no_token() {
|
||||
// fetchAndUnwrapKeys with no keyFetchToken should trigger signOut
|
||||
add_test(function test_fetchAndUnwrapKeys_no_token() {
|
||||
do_test_pending();
|
||||
|
||||
let fxa = new MockFxAccounts();
|
||||
@ -314,7 +314,7 @@ add_test(function test_getKeys_no_token() {
|
||||
delete user.keyFetchToken
|
||||
|
||||
makeObserver(ONLOGOUT_NOTIFICATION, function() {
|
||||
log.debug("test_getKeys_no_token observed logout");
|
||||
log.debug("test_fetchAndUnwrapKeys_no_token observed logout");
|
||||
fxa.internal.getUserAccountData().then(user => {
|
||||
do_test_finished();
|
||||
run_next_test();
|
||||
@ -322,7 +322,7 @@ add_test(function test_getKeys_no_token() {
|
||||
});
|
||||
|
||||
fxa.setSignedInUser(user).then((user) => {
|
||||
fxa.internal.getKeys();
|
||||
fxa.internal.fetchAndUnwrapKeys();
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user