Bug 1730151 - Ask for username if not set in the SMTP auth prompt. r=mkmelin a=wsmwk
authorPing Chen <remotenonsense@gmail.com>
Mon, 13 Sep 2021 13:24:45 +0300
changeset 43405 6a2f149f633567c2f38ff00f764ad58b04fe2429
parent 43404 ee5e8e4ad4308b94c28e672d8c7c082d0239d281
child 43406 e0ab4ea96f464372ec62a73b73a80abff55d592f
push id30
push userthunderbird@calypsoblue.org
push dateFri, 24 Sep 2021 21:34:38 +0000
treeherdercomm-esr91@f6bebff25dd4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, wsmwk
bugs1730151
Bug 1730151 - Ask for username if not set in the SMTP auth prompt. r=mkmelin a=wsmwk Differential Revision: https://phabricator.services.mozilla.com/D125367
mailnews/compose/src/SmtpServer.jsm
--- a/mailnews/compose/src/SmtpServer.jsm
+++ b/mailnews/compose/src/SmtpServer.jsm
@@ -200,25 +200,41 @@ SmtpServer.prototype = {
   },
 
   getPasswordWithUI(promptMessage, promptTitle, prompt) {
     let password = this._getPasswordWithoutUI();
     if (password) {
       this.password = password;
       return this.password;
     }
+    let outUsername = {};
     let outPassword = {};
-    let ok = prompt.promptPassword(
-      promptTitle,
-      promptMessage,
-      this.serverURI,
-      Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY,
-      outPassword
-    );
+    let ok;
+    if (this.username) {
+      ok = prompt.promptPassword(
+        promptTitle,
+        promptMessage,
+        this.serverURI,
+        Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY,
+        outPassword
+      );
+    } else {
+      ok = prompt.promptUsernameAndPassword(
+        promptTitle,
+        promptMessage,
+        this.serverURI,
+        Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY,
+        outUsername,
+        outPassword
+      );
+    }
     if (ok) {
+      if (outUsername.value) {
+        this.username = outUsername.value;
+      }
       this.password = outPassword.value;
     }
     return this.password;
   },
 
   forgetPassword() {
     let serverURI = this._getServerURI();
     let logins = Services.logins.findLogins(serverURI, "", serverURI);