diff options
author | Mavridis Philippe <mavridisf@gmail.com> | 2022-11-26 11:17:02 +0200 |
---|---|---|
committer | Mavridis Philippe <mavridisf@gmail.com> | 2022-12-07 13:22:55 +0200 |
commit | c8bafb9faa4e8b69721798c29dc3b3d6232d27ac (patch) | |
tree | 05ec1d3aca9d22504e72f4c35672b3ded6ff7fe9 /mailnews | |
parent | b019e959d40f7b7ad5c163d041d0ee6965445804 (diff) | |
download | uxp-c8bafb9faa4e8b69721798c29dc3b3d6232d27ac.tar.gz |
MailNews: Re-check availability of OAuth2 when hostname fields modified.
This is for those cases where the hostnme of the email address is not
the actual hostname of the e-mail service (e.g. GMail with a custom
domain).
This should resolve issue athenian200/epyrus#53.
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
Diffstat (limited to 'mailnews')
-rw-r--r-- | mailnews/base/prefs/content/accountcreation/emailWizard.js | 74 | ||||
-rw-r--r-- | mailnews/base/prefs/content/accountcreation/emailWizard.xul | 2 |
2 files changed, 48 insertions, 28 deletions
diff --git a/mailnews/base/prefs/content/accountcreation/emailWizard.js b/mailnews/base/prefs/content/accountcreation/emailWizard.js index 2e4a44e2a0..5a594b16f7 100644 --- a/mailnews/base/prefs/content/accountcreation/emailWizard.js +++ b/mailnews/base/prefs/content/accountcreation/emailWizard.js @@ -1007,6 +1007,50 @@ EmailConfigWizard.prototype = }, /** + * Checks whether OAuth2 is supported by current incoming hostname. + */ + checkIncomingSupportsOAuth2 : function() { +#ifdef MOZ_MAILNEWS_OAUTH2 + var config = this.getUserConfig(); + + // If the hostname supports OAuth2 and imap is enabled, enable OAuth2. + let iDetails = OAuth2Providers.getHostnameDetails(config.incoming.hostname); + gEmailWizardLogger.info("OAuth2 details for incoming hostname " + + config.incoming.hostname + " is " + iDetails); + e("in-authMethod-oauth2").hidden = !(iDetails && e("incoming_protocol").value == 1); + if (!e("in-authMethod-oauth2").hidden) { + config.oauthSettings = {}; + [config.oauthSettings.issuer, config.oauthSettings.scope] = iDetails; + // oauthsettings are not stored nor changable in the user interface, so just + // store them in the base configuration. + this._currentConfig.oauthSettings = config.oauthSettings; + } +#endif + }, + + /** + * Checks whether OAuth2 is supported by current outgoing hostname. + */ + checkOutgoingSupportsOAuth2 : function() { +#ifdef MOZ_MAILNEWS_OAUTH2 + var config = this.getUserConfig(); + + // If the hostname supports OAuth2 and imap is enabled, enable OAuth2. + let oDetails = OAuth2Providers.getHostnameDetails(config.outgoing.hostname); + gEmailWizardLogger.info("OAuth2 details for outgoing hostname " + + config.outgoing.hostname + " is " + oDetails); + e("out-authMethod-oauth2").hidden = !oDetails; + if (!e("out-authMethod-oauth2").hidden) { + config.oauthSettings = {}; + [config.oauthSettings.issuer, config.oauthSettings.scope] = oDetails; + // oauthsettings are not stored nor changable in the user interface, so just + // store them in the base configuration. + this._currentConfig.oauthSettings = config.oauthSettings; + } +#endif + }, + + /** * Fills the manual edit textfields with the provided config. * @param config {AccountConfig} The config to present to user */ @@ -1034,20 +1078,7 @@ EmailConfigWizard.prototype = } this.fillPortDropdown(config.incoming.type); -#ifdef MOZ_MAILNEWS_OAUTH2 - // If the hostname supports OAuth2 and imap is enabled, enable OAuth2. - let iDetails = OAuth2Providers.getHostnameDetails(config.incoming.hostname); - gEmailWizardLogger.info("OAuth2 details for incoming hostname " + - config.incoming.hostname + " is " + iDetails); - e("in-authMethod-oauth2").hidden = !(iDetails && e("incoming_protocol").value == 1); - if (!e("in-authMethod-oauth2").hidden) { - config.oauthSettings = {}; - [config.oauthSettings.issuer, config.oauthSettings.scope] = iDetails; - // oauthsettings are not stored nor changable in the user interface, so just - // store them in the base configuration. - this._currentConfig.oauthSettings = config.oauthSettings; - } -#endif + this.checkIncomingSupportsOAuth2(); // outgoing server e("outgoing_hostname").value = config.outgoing.hostname; @@ -1065,20 +1096,7 @@ EmailConfigWizard.prototype = this.adjustOutgoingPortToSSLAndProtocol(config); } -#ifdef MOZ_MAILNEWS_OAUTH2 - // If the hostname supports OAuth2 and imap is enabled, enable OAuth2. - let oDetails = OAuth2Providers.getHostnameDetails(config.outgoing.hostname); - gEmailWizardLogger.info("OAuth2 details for outgoing hostname " + - config.outgoing.hostname + " is " + oDetails); - e("out-authMethod-oauth2").hidden = !oDetails; - if (!e("out-authMethod-oauth2").hidden) { - config.oauthSettings = {}; - [config.oauthSettings.issuer, config.oauthSettings.scope] = oDetails; - // oauthsettings are not stored nor changable in the user interface, so just - // store them in the base configuration. - this._currentConfig.oauthSettings = config.oauthSettings; - } -#endif + this.checkOutgoingSupportsOAuth2(); // populate fields even if existingServerKey, in case user changes back if (config.outgoing.existingServerKey) { diff --git a/mailnews/base/prefs/content/accountcreation/emailWizard.xul b/mailnews/base/prefs/content/accountcreation/emailWizard.xul index 0ffb5f9459..2487181d48 100644 --- a/mailnews/base/prefs/content/accountcreation/emailWizard.xul +++ b/mailnews/base/prefs/content/accountcreation/emailWizard.xul @@ -276,6 +276,7 @@ </menulist> <textbox id="incoming_hostname" oninput="gEmailConfigWizard.onInputHostname();" + onblur="gEmailConfigWizard.checkIncomingSupportsOAuth2();" class="host uri-element"/> <menulist id="incoming_port" editable="true" @@ -325,6 +326,7 @@ editable="true" sizetopopup="none" oninput="gEmailConfigWizard.onInputHostname();" + onblur="gEmailConfigWizard.checkOutgoingSupportsOAuth2();" oncommand="gEmailConfigWizard.onChangedOutgoingDropdown();" onpopupshowing="gEmailConfigWizard.onOpenOutgoingDropdown();" class="host uri-element"> |