Bug 1528136 - rename loginUrl to loginOrigin, since it's an Origin and not a URL. r=Fallen DONTBUILD
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Thu, 16 Apr 2020 13:51:23 +0300
changeset 38856 7c79228f232df09e1f6787a62444decd311668c8
parent 38855 00b5ea7d8c05ba5053e66fad8a657c3b9606c092
child 38857 cc0eebd9ddbd3bdec2752fb77692413f2c87d4cd
push id401
push userclokep@gmail.com
push dateMon, 01 Jun 2020 20:41:59 +0000
reviewersFallen
bugs1528136
Bug 1528136 - rename loginUrl to loginOrigin, since it's an Origin and not a URL. r=Fallen DONTBUILD
mailnews/base/src/OAuth2Module.jsm
--- a/mailnews/base/src/OAuth2Module.jsm
+++ b/mailnews/base/src/OAuth2Module.jsm
@@ -67,19 +67,19 @@ OAuth2Module.prototype = {
       tokenEndpoint,
     ] = OAuth2Providers.getIssuerDetails(issuer);
     if (!clientId) {
       return false;
     }
 
     // Username is needed to generate the XOAUTH2 string.
     this._username = aUsername;
-    // LoginURL is needed to save the refresh token in the password manager.
-    this._loginUrl = "oauth://" + issuer;
-    // We use the scope to indicate the realm.
+    // loginOrigin is needed to save the refresh token in the password manager.
+    this._loginOrigin = "oauth://" + issuer;
+    // We use the scope to indicate realm when storing in the password manager.
     this._scope = scope;
 
     // Define the OAuth property and store it.
     this._oauth = new OAuth2(
       authorizationEndpoint,
       tokenEndpoint,
       scope,
       clientId,
@@ -99,28 +99,36 @@ OAuth2Module.prototype = {
       get: () => this.refreshToken,
       set: token => (this.refreshToken = token),
     });
 
     return true;
   },
 
   get refreshToken() {
-    let logins = Services.logins.findLogins(this._loginUrl, null, this._scope);
+    let logins = Services.logins.findLogins(
+      this._loginOrigin,
+      null,
+      this._scope
+    );
     for (let login of logins) {
       if (login.username == this._username) {
         return login.password;
       }
     }
     return "";
   },
   set refreshToken(token) {
     // Check if we already have a login with this username, and modify the
     // password on that, if we do.
-    let logins = Services.logins.findLogins(this._loginUrl, null, this._scope);
+    let logins = Services.logins.findLogins(
+      this._loginOrigin,
+      null,
+      this._scope
+    );
     for (let login of logins) {
       if (login.username == this._username) {
         if (token) {
           let propBag = Cc["@mozilla.org/hash-property-bag;1"].createInstance(
             Ci.nsIWritablePropertyBag
           );
           propBag.setProperty("password", token);
           Services.logins.modifyLogin(login, propBag);
@@ -132,17 +140,17 @@ OAuth2Module.prototype = {
     }
 
     // Unless the token is null, we need to create and fill in a new login
     if (token) {
       let login = Cc["@mozilla.org/login-manager/loginInfo;1"].createInstance(
         Ci.nsILoginInfo
       );
       login.init(
-        this._loginUrl,
+        this._loginOrigin,
         null,
         this._scope,
         this._username,
         token,
         "",
         ""
       );
       Services.logins.addLogin(login);
@@ -183,12 +191,12 @@ OAuth2Module.prototype = {
         aListener.onFailure(Cr.NS_ERROR_ABORT);
       },
       onPromptStart() {},
     };
 
     let asyncprompter = Cc[
       "@mozilla.org/messenger/msgAsyncPrompter;1"
     ].getService(Ci.nsIMsgAsyncPrompter);
-    let promptkey = this._loginUrl + "/" + this._username;
+    let promptkey = this._loginOrigin + "/" + this._username;
     asyncprompter.queueAsyncAuthPrompt(promptkey, false, promptlistener);
   },
 };