Bug 1262272 - Unconditionally poll the verification status for FxA push messages. r?markh
MozReview-Commit-ID: Fb7F1bxHO8V
--- a/services/fxaccounts/FxAccounts.jsm
+++ b/services/fxaccounts/FxAccounts.jsm
@@ -416,17 +416,18 @@ FxAccountsInternal.prototype = {
/**
* Ask the server whether the user's email has been verified
*/
checkEmailStatus: function checkEmailStatus(sessionToken, options = {}) {
if (!sessionToken) {
return Promise.reject(new Error(
"checkEmailStatus called without a session token"));
}
- return this.fxAccountsClient.recoveryEmailStatus(sessionToken, options);
+ return this.fxAccountsClient.recoveryEmailStatus(sessionToken,
+ options).catch(error => this._handleTokenError(error));
},
/**
* Once the user's email is verified, we can request the keys
*/
fetchKeys: function fetchKeys(keyFetchToken) {
log.debug("fetchKeys: " + !!keyFetchToken);
if (logPII) {
@@ -668,20 +669,25 @@ FxAccountsInternal.prototype = {
log.trace('checkVerificationStatus');
let currentState = this.currentAccountState;
return currentState.getUserAccountData().then(data => {
if (!data) {
log.trace("checkVerificationStatus - no user data");
return null;
}
- if (!this.isUserEmailVerified(data)) {
+ // Always check the verification status, even if the local state indicates
+ // we're already verified. If the user changed their password, the check
+ // will fail, and we'll enter the reauth state.
+ if (this.isUserEmailVerified(data)) {
+ log.trace("checkVerificationStatus - checking status for verified account");
+ } else {
log.trace("checkVerificationStatus - forcing verification status check");
- this.pollEmailStatus(currentState, data.sessionToken, "push");
}
+ this.pollEmailStatus(currentState, data.sessionToken, "push");
});
},
_destroyOAuthToken: function(tokenData) {
let client = new FxAccountsOAuthGrantClient({
serverURL: tokenData.server,
client_id: FX_OAUTH_CLIENT_ID
});