diff options
author | Julen Landa Alustiza <julen@zokormazo.info> | 2017-03-30 19:13:57 +0200 |
---|---|---|
committer | Julen Landa Alustiza <julen@zokormazo.info> | 2017-03-30 19:13:57 +0200 |
commit | db2c381c005269557018b560a04abd0f59dfc7aa (patch) | |
tree | 41d3c77e351c463bf7c189358dde19e871dc4c5c | |
parent | ee6aa7a6b20a3839f92d91e9bc24136aa07306b9 (diff) | |
download | wekan-db2c381c005269557018b560a04abd0f59dfc7aa.tar.gz wekan-db2c381c005269557018b560a04abd0f59dfc7aa.tar.bz2 wekan-db2c381c005269557018b560a04abd0f59dfc7aa.zip |
Add TLS toggle option to smtp configuration
-rw-r--r-- | client/components/settings/settingBody.jade | 12 | ||||
-rw-r--r-- | client/components/settings/settingBody.js | 8 | ||||
-rw-r--r-- | i18n/en.i18n.json | 2 | ||||
-rw-r--r-- | models/settings.js | 18 |
4 files changed, 30 insertions, 10 deletions
diff --git a/client/components/settings/settingBody.jade b/client/components/settings/settingBody.jade index fdab3173..d490ec93 100644 --- a/client/components/settings/settingBody.jade +++ b/client/components/settings/settingBody.jade @@ -16,7 +16,7 @@ template(name="setting") +general else if emailSetting.get +email - + template(name="general") ul#registration-setting.setting-detail li @@ -63,9 +63,17 @@ template(name='email') .form-group input.form-control#mail-server-password(type="text", placeholder="{{_ 'password'}}" value="{{currentSetting.mailServer.password}}") li.smtp-form + .title {{_ 'smtp-tls'}} + .form-group + a.flex.js-toggle-tls + .materialCheckBox#mail-server-tls(class="{{#if currentSetting.mailServer.enableTLS}}is-checked{{/if}}") + + span {{_ 'smtp-tls-description'}} + + li.smtp-form .title {{_ 'send-from'}} .form-group input.form-control#mail-server-from(type="email", placeholder="no-reply@domain.com" value="{{currentSetting.mailServer.from}}") li - button.js-save.primary Save + button.js-save.primary Save diff --git a/client/components/settings/settingBody.js b/client/components/settings/settingBody.js index 0dc3c5f0..f96312a5 100644 --- a/client/components/settings/settingBody.js +++ b/client/components/settings/settingBody.js @@ -51,7 +51,9 @@ BlazeComponent.extendComponent({ $('.invite-people').slideDown(); } }, - + toggleTLS(){ + $('#mail-server-tls').toggleClass('is-checked'); + }, switchMenu(event){ const target = $(event.target); if(!target.hasClass('active')){ @@ -106,8 +108,9 @@ BlazeComponent.extendComponent({ const username = $('#mail-server-username').val().trim(); const password = $('#mail-server-password').val().trim(); const from = this.checkField('#mail-server-from'); + const tls = $('#mail-server-tls.is-checked').length > 0; Settings.update(Settings.findOne()._id, {$set:{'mailServer.host':host, 'mailServer.port': port, 'mailServer.username': username, - 'mailServer.password': password, 'mailServer.from': from}}); + 'mailServer.password': password, 'mailServer.enableTLS': tls, 'mailServer.from': from}}); } catch (e) { return; } finally { @@ -119,6 +122,7 @@ BlazeComponent.extendComponent({ events(){ return [{ 'click a.js-toggle-registration': this.toggleRegistration, + 'click a.js-toggle-tls': this.toggleTLS, 'click a.js-setting-menu': this.switchMenu, 'click a.js-toggle-board-choose': this.checkBoard, 'click button.js-email-invite': this.inviteThroughEmail, diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 19734045..ecf145d0 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -337,10 +337,12 @@ "email-addresses": "Email Addresses", "smtp-host-description": "The address of the SMTP server that handles your emails.", "smtp-port-description": "The port your SMTP server uses for outgoing emails.", + "smtp-tls-description": "Enable TLS support for SMTP server", "smtp-host": "SMTP Host", "smtp-port": "SMTP Port", "smtp-username": "Username", "smtp-password": "Password", + "smtp-tls": "TLS support", "send-from": "From", "invitation-code": "Invitation Code", "email-invite-register-subject": "__inviter__ sent you an invitation", diff --git a/models/settings.js b/models/settings.js index 0c2da4d3..e5b9783a 100644 --- a/models/settings.js +++ b/models/settings.js @@ -20,6 +20,10 @@ Settings.attachSchema(new SimpleSchema({ type: String, optional: true, }, + 'mailServer.enableTLS': { + type: Boolean, + optional: true, + }, 'mailServer.from': { type: String, optional: true, @@ -38,10 +42,11 @@ Settings.helpers({ if (!this.mailServer.host) { return null; } + const protocol = this.mailServer.enableTLS ? 'smtps://' : 'smtp://'; if (!this.mailServer.username && !this.mailServer.password) { - return `smtp://${this.mailServer.host}:${this.mailServer.port}/`; + return `${protocol}${this.mailServer.host}:${this.mailServer.port}/`; } - return `smtp://${this.mailServer.username}:${this.mailServer.password}@${this.mailServer.host}:${this.mailServer.port}/`; + return `${protocol}${this.mailServer.username}:${this.mailServer.password}@${this.mailServer.host}:${this.mailServer.port}/`; }, }); Settings.allow({ @@ -62,7 +67,7 @@ if (Meteor.isServer) { if(!setting){ const now = new Date(); const defaultSetting = {disableRegistration: false, mailServer: { - username: '', password:'', host: '', port:'', from: '', + username: '', password: '', host: '', port: '', enableTLS: false, from: '', }, createdAt: now, modifiedAt: now}; Settings.insert(defaultSetting); } @@ -72,11 +77,12 @@ if (Meteor.isServer) { }); Settings.after.update((userId, doc, fieldNames) => { // assign new values to mail-from & MAIL_URL in environment - if (_.contains(fieldNames, 'mailServer') && _.contains(fieldNames, 'host')) { + if (_.contains(fieldNames, 'mailServer') && doc.mailServer.host) { + const protocol = doc.mailServer.enableTLS ? 'smtps://' : 'smtp://'; if (!doc.mailServer.username && !doc.mailServer.password) { - process.env.MAIL_URL = `smtp://${doc.mailServer.host}:${doc.mailServer.port}/`; + process.env.MAIL_URL = `${protocol}${doc.mailServer.host}:${doc.mailServer.port}/`; } else { - process.env.MAIL_URL = `smtp://${doc.mailServer.username}:${doc.mailServer.password}@${doc.mailServer.host}:${doc.mailServer.port}/`; + process.env.MAIL_URL = `${protocol}${doc.mailServer.username}:${doc.mailServer.password}@${doc.mailServer.host}:${doc.mailServer.port}/`; } Accounts.emailTemplates.from = doc.mailServer.from; } |