Turn off SSL/TLS by default if the user selects ports 143, 25

This commit is contained in:
Ben Gotow 2017-10-11 12:23:08 -07:00
parent 03131a8acb
commit 65fcb48c37
2 changed files with 27 additions and 5 deletions

View file

@ -84,6 +84,25 @@ class AccountIMAPSettingsForm extends React.Component {
const isStandard = values.includes(settings[field] / 1);
const customValue = isStandard ? '0' : settings[field];
// When you change the port, automatically switch the security setting to
// the standard for that port. Lots of people don't update that field and
// are getting confused.
const onPortChange = event => {
onFieldChange(event);
if (event.target.value / 1 === 143 && settings.imap_security !== 'none') {
onFieldChange({ target: { value: 'none', id: 'settings.imap_security' } });
}
if (event.target.value / 1 === 993 && settings.imap_security !== 'SSL / TLS') {
onFieldChange({ target: { value: 'SSL / TLS', id: 'settings.imap_security' } });
}
if (event.target.value / 1 === 25 && settings.smtp_security !== 'none') {
onFieldChange({ target: { value: 'none', id: 'settings.smtp_security' } });
}
if (event.target.value / 1 === 587 && settings.smtp_security !== 'STARTTLS') {
onFieldChange({ target: { value: 'STARTTLS', id: 'settings.smtp_security' } });
}
};
return (
<span>
<label htmlFor={`settings.${field}`}>Port:</label>
@ -92,8 +111,7 @@ class AccountIMAPSettingsForm extends React.Component {
tabIndex={0}
value={settings[field]}
disabled={submitting}
onKeyPress={onFieldKeyPress}
onChange={onFieldChange}
onChange={onPortChange}
>
{values.map(v => (
<option value={v} key={v}>
@ -138,7 +156,7 @@ class AccountIMAPSettingsForm extends React.Component {
onKeyPress={onFieldKeyPress}
onChange={onFieldChange}
>
<option value="SSL / TLS" key="SSL">
<option value="SSL / TLS" key="SSL / TLS">
SSL / TLS
</option>
<option value="STARTTLS" key="STARTTLS">

View file

@ -1,4 +1,4 @@
import { React, PropTypes, RegExpUtils } from 'mailspring-exports';
import { Account, React, PropTypes, RegExpUtils } from 'mailspring-exports';
import OnboardingActions from './onboarding-actions';
import CreatePageForForm from './decorators/create-page-for-form';
@ -54,8 +54,12 @@ class AccountBasicSettingsForm extends React.Component {
};
submit() {
const account = expandAccountWithCommonSettings(this.props.account);
// create a new account with expanded settings and just the three fields
const { name, emailAddress, provider, settings: { imap_password } } = this.props.account;
let account = new Account({ name, emailAddress, provider, settings: { imap_password } });
account = expandAccountWithCommonSettings(account);
OnboardingActions.setAccount(account);
if (this.props.account.provider === 'imap') {
OnboardingActions.moveToPage('account-settings-imap');
} else {