summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2017-03-12 16:11:33 +0200
committerLauri Ojansivu <x@xet7.org>2017-03-12 16:11:33 +0200
commit6b1b452c4a21f15a2856f8815e47ac794e1a2841 (patch)
tree33ac5bcfbdd6f35060051093bc66f6e91af0a018
parentde396e6c6bb803658eed729b46774a5598073b53 (diff)
parent72c3651be4365d3b903d694e55a3ea373d260709 (diff)
downloadwekan-6b1b452c4a21f15a2856f8815e47ac794e1a2841.tar.gz
wekan-6b1b452c4a21f15a2856f8815e47ac794e1a2841.tar.bz2
wekan-6b1b452c4a21f15a2856f8815e47ac794e1a2841.zip
Merge branch 'admin-panel' of https://github.com/lkisme/wekan into lkisme-admin-panel
-rw-r--r--client/components/settings/settingBody.js4
-rw-r--r--models/settings.js23
2 files changed, 22 insertions, 5 deletions
diff --git a/client/components/settings/settingBody.js b/client/components/settings/settingBody.js
index 5ae982f7..0dc3c5f0 100644
--- a/client/components/settings/settingBody.js
+++ b/client/components/settings/settingBody.js
@@ -103,8 +103,8 @@ BlazeComponent.extendComponent({
try{
const host = this.checkField('#mail-server-host');
const port = this.checkField('#mail-server-port');
- const username = this.checkField('#mail-server-username');
- const password = this.checkField('#mail-server-password');
+ const username = $('#mail-server-username').val().trim();
+ const password = $('#mail-server-password').val().trim();
const from = this.checkField('#mail-server-from');
Settings.update(Settings.findOne()._id, {$set:{'mailServer.host':host, 'mailServer.port': port, 'mailServer.username': username,
'mailServer.password': password, 'mailServer.from': from}});
diff --git a/models/settings.js b/models/settings.js
index b9ff1b37..0e6ab762 100644
--- a/models/settings.js
+++ b/models/settings.js
@@ -35,8 +35,10 @@ Settings.attachSchema(new SimpleSchema({
}));
Settings.helpers({
mailUrl () {
- const mailUrl = `smtp://${this.mailServer.username}:${this.mailServer.password}@${this.mailServer.host}:${this.mailServer.port}/`;
- return mailUrl;
+ if (!this.mailServer.username && !this.mailServer.password) {
+ return `smtp://${this.mailServer.host}:${this.mailServer.port}/`;
+ }
+ return `smtp://${this.mailServer.username}:${this.mailServer.password}@${this.mailServer.host}:${this.mailServer.port}/`;
},
});
Settings.allow({
@@ -65,6 +67,17 @@ if (Meteor.isServer) {
process.env.MAIL_URL = newSetting.mailUrl();
Accounts.emailTemplates.from = newSetting.mailServer.from;
});
+ Settings.after.update((userId, doc, fieldNames) => {
+ // assign new values to mail-from & MAIL_URL in environment
+ if (_.contains(fieldNames, 'mailServer')) {
+ if (!doc.mailServer.username && !doc.mailServer.password) {
+ process.env.MAIL_URL = `smtp://${doc.mailServer.host}:${doc.mailServer.port}/`;
+ } else {
+ process.env.MAIL_URL = `smtp://${doc.mailServer.username}:${doc.mailServer.password}@${doc.mailServer.host}:${doc.mailServer.port}/`;
+ }
+ Accounts.emailTemplates.from = doc.mailServer.from;
+ }
+ });
function getRandomNum (min, max) {
const range = max - min;
@@ -107,7 +120,11 @@ if (Meteor.isServer) {
if (email && SimpleSchema.RegEx.Email.test(email)) {
const code = getRandomNum(100000, 999999);
InvitationCodes.insert({code, email, boardsToBeInvited: boards, createdAt: new Date(), authorId: Meteor.userId()}, function(err, _id){
- if(!err && _id) sendInvitationEmail(_id);
+ if (!err && _id) {
+ sendInvitationEmail(_id);
+ } else {
+ throw new Meteor.Error('invitation-generated-fail', err.message);
+ }
});
}
});