mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-12 02:58:20 +08:00
[iso-core] Let auth methods accept all supported providers
Summary: Treat any that aren't gmail or office365 as standard imap Test Plan: manual Reviewers: juan, evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D3686
This commit is contained in:
parent
ae981af646
commit
c5453ca21b
1 changed files with 17 additions and 12 deletions
|
@ -35,6 +35,10 @@ const USER_ERRORS = {
|
|||
IMAP_RETRY: "We were unable to reach your mail provider. Please try again.",
|
||||
}
|
||||
|
||||
const SUPPORTED_PROVIDERS = new Set(
|
||||
['gmail', 'office365', 'imap', 'icloud', 'yahoo', 'fastmail']
|
||||
);
|
||||
|
||||
function credentialsForProvider({provider, settings, email}) {
|
||||
if (provider === "gmail") {
|
||||
const connectionSettings = {
|
||||
|
@ -51,17 +55,6 @@ function credentialsForProvider({provider, settings, email}) {
|
|||
expiry_date: settings.expiry_date,
|
||||
}
|
||||
return {connectionSettings, connectionCredentials}
|
||||
} else if (provider === "imap") {
|
||||
const connectionSettings = _.pick(settings, [
|
||||
'imap_host', 'imap_port',
|
||||
'smtp_host', 'smtp_port',
|
||||
'ssl_required', 'smtp_custom_config',
|
||||
]);
|
||||
const connectionCredentials = _.pick(settings, [
|
||||
'imap_username', 'imap_password',
|
||||
'smtp_username', 'smtp_password',
|
||||
]);
|
||||
return {connectionSettings, connectionCredentials}
|
||||
} else if (provider === "office365") {
|
||||
const connectionSettings = {
|
||||
imap_host: 'outlook.office365.com',
|
||||
|
@ -74,6 +67,7 @@ function credentialsForProvider({provider, settings, email}) {
|
|||
tls: {ciphers: 'SSLv3'},
|
||||
},
|
||||
}
|
||||
|
||||
const connectionCredentials = {
|
||||
imap_username: email,
|
||||
imap_password: settings.password,
|
||||
|
@ -81,6 +75,17 @@ function credentialsForProvider({provider, settings, email}) {
|
|||
smtp_password: settings.password,
|
||||
}
|
||||
return {connectionSettings, connectionCredentials}
|
||||
} else if (SUPPORTED_PROVIDERS.has(provider)) {
|
||||
const connectionSettings = _.pick(settings, [
|
||||
'imap_host', 'imap_port',
|
||||
'smtp_host', 'smtp_port',
|
||||
'ssl_required', 'smtp_custom_config',
|
||||
]);
|
||||
const connectionCredentials = _.pick(settings, [
|
||||
'imap_username', 'imap_password',
|
||||
'smtp_username', 'smtp_password',
|
||||
]);
|
||||
return {connectionSettings, connectionCredentials}
|
||||
}
|
||||
throw new Error(`Invalid provider: ${provider}`)
|
||||
}
|
||||
|
@ -95,7 +100,7 @@ module.exports = {
|
|||
payload: {
|
||||
email: Joi.string().email().required(),
|
||||
name: Joi.string().required(),
|
||||
provider: Joi.string().valid('imap', 'gmail', 'office365').required(),
|
||||
provider: Joi.string().valid(...SUPPORTED_PROVIDERS).required(),
|
||||
settings: Joi.alternatives().try(imapSmtpSettings, office365Settings, resolvedGmailSettings),
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue