From 581e2f23ccc7e309d0963fc54c6f2ba4457d9a81 Mon Sep 17 00:00:00 2001 From: Mark Hammond Date: Thu, 18 Dec 2014 16:14:58 +1100 Subject: [PATCH] Bug 1109430 - Sync migrator module should show confirmation after resending verification email. r=adw --- browser/base/content/browser-fxaccounts.js | 4 ++- .../components/preferences/in-content/sync.js | 8 +++--- browser/components/preferences/sync.js | 8 +++--- .../en-US/chrome/browser/accounts.properties | 11 ++++++++ .../preferences/preferences.properties | 6 ----- services/sync/modules/FxaMigrator.jsm | 27 +++++++++++++++++-- 6 files changed, 47 insertions(+), 17 deletions(-) diff --git a/browser/base/content/browser-fxaccounts.js b/browser/base/content/browser-fxaccounts.js index 5dcdbcb12c38..5873206bc890 100644 --- a/browser/base/content/browser-fxaccounts.js +++ b/browser/base/content/browser-fxaccounts.js @@ -331,7 +331,9 @@ let gFxAccounts = { fxaMigrator.createFxAccount(window); break; case "migrate-verify": - fxaMigrator.resendVerificationMail(); + // Instead of using the migrator module directly here the UX calls for + // us to open prefs which has a "resend" button. + this.openPreferences(); break; default: this.openAccountsPage(null, { entryPoint: "menupanel" }); diff --git a/browser/components/preferences/in-content/sync.js b/browser/components/preferences/in-content/sync.js index 265f2482e5fe..e234738ab50e 100644 --- a/browser/components/preferences/in-content/sync.js +++ b/browser/components/preferences/in-content/sync.js @@ -448,11 +448,11 @@ let gSyncPane = { verifyFirefoxAccount: function() { fxAccounts.resendVerificationEmail().then(() => { fxAccounts.getSignedInUser().then(data => { - let sb = this._stringBundle; - let title = sb.GetStringFromName("firefoxAccountsVerificationSentTitle"); - let heading = sb.formatStringFromName("firefoxAccountsVerificationSentHeading", + let sb = this._accountsStringBundle; + let title = sb.GetStringFromName("verificationSentTitle"); + let heading = sb.formatStringFromName("verificationSentHeading", [data.email], 1); - let description = sb.GetStringFromName("firefoxAccountVerificationSentDescription"); + let description = sb.GetStringFromName("verificationSentDescription"); let factory = Cc["@mozilla.org/prompter;1"] .getService(Ci.nsIPromptFactory); diff --git a/browser/components/preferences/sync.js b/browser/components/preferences/sync.js index 3133cc042500..80e74b1ed053 100644 --- a/browser/components/preferences/sync.js +++ b/browser/components/preferences/sync.js @@ -285,11 +285,11 @@ let gSyncPane = { Components.utils.import("resource://gre/modules/FxAccounts.jsm"); fxAccounts.resendVerificationEmail().then(() => { fxAccounts.getSignedInUser().then(data => { - let sb = this._stringBundle; - let title = sb.GetStringFromName("firefoxAccountsVerificationSentTitle"); - let heading = sb.formatStringFromName("firefoxAccountsVerificationSentHeading", + let sb = Services.strings.createBundle("chrome://browser/locale/accounts.properties"); + let title = sb.GetStringFromName("verificationSentTitle"); + let heading = sb.formatStringFromName("verificationSentHeading", [data.email], 1); - let description = sb.GetStringFromName("firefoxAccountVerificationSentDescription"); + let description = sb.GetStringFromName("verificationSentDescription"); Services.prompt.alert(window, title, heading + "\n\n" + description); }); diff --git a/browser/locales/en-US/chrome/browser/accounts.properties b/browser/locales/en-US/chrome/browser/accounts.properties index edbcd0f31c7e..b2e94ccec18c 100644 --- a/browser/locales/en-US/chrome/browser/accounts.properties +++ b/browser/locales/en-US/chrome/browser/accounts.properties @@ -20,3 +20,14 @@ resendVerificationEmail.accessKey = R forgetMigration.label = Forget forgetMigration.accessKey = F + +# These strings are used in a dialog we display after the user requests we resend +# a verification email. +verificationSentTitle = Verification Sent +# LOCALIZATION NOTE (verificationSentHeading) - %S = Email address of user's Firefox Account +verificationSentHeading = A verification link has been sent to %S +verificationSentDescription = Please check your email and click the link to begin syncing. + +verificationNotSentTitle = Unable to Send Verification +verificationNotSentHeading = We are unable to send a verification mail at this time +verificationNotSentDescription = Please try again later. diff --git a/browser/locales/en-US/chrome/browser/preferences/preferences.properties b/browser/locales/en-US/chrome/browser/preferences/preferences.properties index 00acacf19378..619e015e041a 100644 --- a/browser/locales/en-US/chrome/browser/preferences/preferences.properties +++ b/browser/locales/en-US/chrome/browser/preferences/preferences.properties @@ -137,9 +137,3 @@ syncUnlinkConfirm.label=Unlink featureEnableRequiresRestart=%S must restart to enable this feature. featureDisableRequiresRestart=%S must restart to disable this feature. shouldRestartTitle=Restart %S - -###Preferences::Sync::Firefox Accounts -firefoxAccountsVerificationSentTitle=Verification Sent -# LOCALIZATION NOTE: %S = user's email address. -firefoxAccountsVerificationSentHeading=A verification link has been sent to %S -firefoxAccountVerificationSentDescription=Please check your email and click the link to begin syncing. diff --git a/services/sync/modules/FxaMigrator.jsm b/services/sync/modules/FxaMigrator.jsm index a99d766803e7..68269025c290 100644 --- a/services/sync/modules/FxaMigrator.jsm +++ b/services/sync/modules/FxaMigrator.jsm @@ -350,12 +350,35 @@ Migrator.prototype = { // STATE_USER_FXA_VERIFIED state. When the user clicks on the link in // the mail we should see an ONVERIFIED_NOTIFICATION which will cause us // to complete the migration. - resendVerificationMail: Task.async(function * () { + resendVerificationMail: Task.async(function * (win) { // warn if we aren't in the expected state - but go ahead anyway! if (this._state != this.STATE_USER_FXA_VERIFIED) { this.log.warn("createFxAccount called in an unexpected state: ${}", this._state); } - return fxAccounts.resendVerificationEmail(); + let ok = true; + try { + yield fxAccounts.resendVerificationEmail(); + } catch (ex) { + this.log.error("Failed to resend verification mail: ${}", ex); + ok = false; + } + let fxauser = yield fxAccounts.getSignedInUser(); + let sb = Services.strings.createBundle("chrome://browser/locale/accounts.properties"); + + let heading = ok ? + sb.formatStringFromName("verificationSentHeading", [fxauser.email], 1) : + sb.GetStringFromName("verificationNotSentHeading"); + let title = sb.GetStringFromName(ok ? "verificationSentTitle" : "verificationNotSentTitle"); + let description = sb.GetStringFromName(ok ? "verificationSentDescription" + : "verificationNotSentDescription"); + + let factory = Cc["@mozilla.org/prompter;1"] + .getService(Ci.nsIPromptFactory); + let prompt = factory.getPrompt(win, Ci.nsIPrompt); + let bag = prompt.QueryInterface(Ci.nsIWritablePropertyBag2); + bag.setPropertyAsBool("allowTabModal", true); + + prompt.alert(title, heading + "\n\n" + description); }), // "forget" about the current Firefox account. This should only be called