Fix Outlook OAuth showing up as Office365 - for now, keep two providers

This commit is contained in:
Ben Gotow 2024-09-14 18:08:47 -05:00
parent becde44839
commit 3df650013f
7 changed files with 25 additions and 10 deletions

View file

@ -33,6 +33,7 @@
</screenshots>
<releases>
<release version="1.14.0" date="2024-09-13" />
<release version="1.13.3" date="2024-01-08" />
<release version="1.13.2" date="2023-12-10" />
<release version="1.13.1" date="2023-11-21" />

View file

@ -2514,23 +2514,21 @@
"alias": "hotmail.com"
},
"hotmail.com": {
"display_name": "Outlook.com (Microsoft)",
"display_name": "Outlook.com",
"display_short_name": "Outlook",
"imap_host": "outlook.office365.com",
"imap_port": "993",
"imap_security": "SSL / TLS",
"imap_user_format": "email",
"imap_authentication": [
"OAuth2",
"password-cleartext"
"OAuth2"
],
"smtp_host": "smtp.office365.com",
"smtp_port": "587",
"smtp_security": "STARTTLS",
"smtp_user_format": "email",
"smtp_authentication": [
"OAuth2",
"password-cleartext"
"OAuth2"
],
"enable_steps": []
},

View file

@ -254,6 +254,17 @@ export async function buildGmailAccountFromAuthResponse(code: string) {
}
export async function buildO365AccountFromAuthResponse(code: string) {
return buildMicrosoftAccountFromAuthResponse(code, 'office365');
}
export async function buildOutlookAccountFromAuthResponse(code: string) {
return buildMicrosoftAccountFromAuthResponse(code, 'outlook');
}
export async function buildMicrosoftAccountFromAuthResponse(
code: string,
provider: 'outlook' | 'office365'
) {
/// Exchange code for an access token
const { access_token, refresh_token } = await fetchPostWithFormBody<TokenResponse>(
`https://login.microsoftonline.com/common/oauth2/v2.0/token`,
@ -285,7 +296,7 @@ export async function buildO365AccountFromAuthResponse(code: string) {
new Account({
name: me.displayName,
emailAddress: me.mail,
provider: 'office365',
provider: provider,
settings: {
refresh_client_id: O365_CLIENT_ID,
refresh_token: refresh_token,

View file

@ -1,7 +1,7 @@
import React from 'react';
import { Account } from 'mailspring-exports';
import { buildO365AccountFromAuthResponse, buildO365AuthURL } from './onboarding-helpers';
import { buildOutlookAccountFromAuthResponse, buildO365AuthURL } from './onboarding-helpers';
import OAuthSignInPage from './oauth-signin-page';
import * as OnboardingActions from './onboarding-actions';
@ -25,7 +25,7 @@ export default class AccountSettingsPageOutlook extends React.Component<{ accoun
serviceName="Outlook"
providerAuthPageUrl={this._authUrl}
providerConfig={providerConfig}
buildAccountFromAuthResponse={buildO365AccountFromAuthResponse}
buildAccountFromAuthResponse={buildOutlookAccountFromAuthResponse}
onSuccess={this.onSuccess}
onTryAgain={goBack}
/>

View file

@ -81,7 +81,8 @@ class InitialPreferencesOptions extends React.Component<
this.props.config.set('core.keymapTemplate', templateWithBasename('Gmail'));
} else if (
this.props.account.provider === 'eas' ||
this.props.account.provider === 'office365'
this.props.account.provider === 'office365' ||
this.props.account.provider === 'outlook'
) {
this.props.config.set('core.workspace.mode', 'split');
this.props.config.set('core.keymapTemplate', templateWithBasename('Outlook'));

View file

@ -190,8 +190,12 @@ export class Account extends ModelWithMetadata {
return 'Yahoo';
} else if (this.provider === 'imap') {
return 'IMAP';
} else if (this.provider === 'yandex') {
return 'Yandex';
} else if (this.provider === 'office365') {
return 'Office 365';
} else if (this.provider === 'outlook') {
return 'Outlook';
}
return this.provider;
}

@ -1 +1 @@
Subproject commit f7f0b7701fea07dd3cbd07eeec59fcf5bbae93ae
Subproject commit 9bb2ac14981e9d4867aa0d38ef6f50e9a2224da7