Bug 1505950 - Ask to save password for CalDAV calendars; r=Fallen
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 31 Dec 2018 12:16:44 +1300
changeset 34084 3375b11b89fa06fcafed9f2fc2b3082b1fa67314
parent 34083 9bc477f5f7d396d1d3d6be9e813759501e70a473
child 34085 1025d59f72597772038884ab12a4e1fc648213c5
push id389
push userclokep@gmail.com
push dateMon, 18 Mar 2019 19:01:53 +0000
reviewersFallen
bugs1505950
Bug 1505950 - Ask to save password for CalDAV calendars; r=Fallen
calendar/base/modules/utils/calAuthUtils.jsm
--- a/calendar/base/modules/utils/calAuthUtils.jsm
+++ b/calendar/base/modules/utils/calAuthUtils.jsm
@@ -99,20 +99,32 @@ var calauth = {
             hostRealm.passwordRealm = aChannel.URI.host + ":" + port + " (" + aAuthInfo.realm + ")";
 
             let pwInfo = this.getPasswordInfo(hostRealm);
             aAuthInfo.username = pwInfo.username;
             if (pwInfo && pwInfo.found) {
                 aAuthInfo.password = pwInfo.password;
                 return true;
             } else {
-                let prompter2 = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
-                                          .getService(Components.interfaces.nsIPromptFactory)
-                                          .getPrompt(this.mWindow, Components.interfaces.nsIAuthPrompt2);
-                return prompter2.promptAuth(aChannel, aLevel, aAuthInfo);
+                let savePasswordLabel = null;
+                if (Preferences.get("signon.rememberSignons", true)) {
+                    savePasswordLabel = cal.l10n.getAnyString("passwordmgr",
+                                                              "passwordmgr",
+                                                              "rememberPassword");
+                }
+                let savePassword = {};
+                let returnValue = Services.prompt.promptAuth(null, aChannel, aLevel, aAuthInfo,
+                                                             savePasswordLabel, savePassword);
+                if (savePassword.value) {
+                    calauth.passwordManagerSave(aAuthInfo.username,
+                                                aAuthInfo.password,
+                                                hostRealm.prePath,
+                                                aAuthInfo.realm);
+                }
+                return returnValue;
             }
         }
 
         // nsICancelable asyncPromptAuth(in nsIChannel aChannel,
         //                               in nsIAuthPromptCallback aCallback,
         //                               in nsISupports aContext,
         //                               in uint32_t level,
         //                               in nsIAuthInformation authInfo);