summaryrefslogtreecommitdiffstats
path: root/mailnews/base/src/msgOAuth2Module.js
diff options
context:
space:
mode:
authorNew Tobin Paradigm <email@mattatobin.com>2019-12-31 20:17:35 -0500
committerGitHub <noreply@github.com>2019-12-31 20:17:35 -0500
commit26b297510a11758727438df4669357a2a2bc42ce (patch)
tree038c36c0214be1e19d11c8bdb58bf82ac4b3a994 /mailnews/base/src/msgOAuth2Module.js
parent357405f6356e28e5fa94cecc078b65c20433d236 (diff)
parent12eb1554f9ff0c0d8dc49da44b6bd0081b1231a1 (diff)
downloadUXP-26b297510a11758727438df4669357a2a2bc42ce.tar
UXP-26b297510a11758727438df4669357a2a2bc42ce.tar.gz
UXP-26b297510a11758727438df4669357a2a2bc42ce.tar.lz
UXP-26b297510a11758727438df4669357a2a2bc42ce.tar.xz
UXP-26b297510a11758727438df4669357a2a2bc42ce.zip
Merge pull request #1340 from g4jc/mailnews_enhance
OAuth2 updates
Diffstat (limited to 'mailnews/base/src/msgOAuth2Module.js')
-rw-r--r--mailnews/base/src/msgOAuth2Module.js42
1 files changed, 33 insertions, 9 deletions
diff --git a/mailnews/base/src/msgOAuth2Module.js b/mailnews/base/src/msgOAuth2Module.js
index 407ab0519..22d5dc572 100644
--- a/mailnews/base/src/msgOAuth2Module.js
+++ b/mailnews/base/src/msgOAuth2Module.js
@@ -126,19 +126,43 @@ OAuth2Module.prototype = {
}
}
- // Otherwise, we need a new login, so create one and fill it in.
- let login = Cc["@mozilla.org/login-manager/loginInfo;1"]
- .createInstance(Ci.nsILoginInfo);
- login.init(this._loginUrl, null, this._scope, this._username, token,
- '', '');
- loginMgr.addLogin(login);
+ // 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, null, this._scope, this._username, token,
+ '', '');
+ loginMgr.addLogin(login);
+ }
return token;
},
connect(aWithUI, aListener) {
- this._oauth.connect(() => aListener.onSuccess(this._oauth.accessToken),
- x => aListener.onFailure(x),
- aWithUI, false);
+ let oauth = this._oauth;
+ let promptlistener = {
+ onPromptStartAsync: function(callback) {
+ oauth.connect(() => {
+ this.onPromptAuthAvailable();
+ callback.onAuthResult(true);
+ }, (err) => {
+ this.onPromptCanceled();
+ callback.onAuthResult(false);
+ }, aWithUI, false);
+ },
+
+ onPromptAuthAvailable: function() {
+ aListener.onSuccess(oauth.accessToken);
+ },
+ onPromptCanceled: function() {
+ aListener.onFailure(Components.results.NS_ERROR_ABORT);
+ },
+ onPromptStart: function() {}
+ };
+
+ let asyncprompter = Components.classes["@mozilla.org/messenger/msgAsyncPrompter;1"]
+ .getService(Components.interfaces.nsIMsgAsyncPrompter);
+ let promptkey = this._loginUrl + "/" + this._username;
+ asyncprompter.queueAsyncAuthPrompt(promptkey, false, promptlistener);
},
buildXOAuth2String() {