summaryrefslogtreecommitdiffstats
path: root/client/components
diff options
context:
space:
mode:
Diffstat (limited to 'client/components')
-rw-r--r--client/components/settings/settingBody.jade16
-rw-r--r--client/components/settings/settingBody.js22
-rw-r--r--client/components/users/userHeader.jade8
-rw-r--r--client/components/users/userHeader.js43
4 files changed, 87 insertions, 2 deletions
diff --git a/client/components/settings/settingBody.jade b/client/components/settings/settingBody.jade
index 1c6e3b7f..5864efd5 100644
--- a/client/components/settings/settingBody.jade
+++ b/client/components/settings/settingBody.jade
@@ -12,6 +12,8 @@ template(name="setting")
a.js-setting-menu(data-id="registration-setting") {{_ 'registration'}}
li
a.js-setting-menu(data-id="email-setting") {{_ 'email'}}
+ li
+ a.js-setting-menu(data-id="account-setting") {{_ 'accounts'}}
.main-body
if loading.get
+spinner
@@ -19,6 +21,8 @@ template(name="setting")
+general
else if emailSetting.get
+email
+ else if accountSetting.get
+ +accountSettings
template(name="general")
ul#registration-setting.setting-detail
@@ -80,3 +84,15 @@ template(name='email')
li
button.js-save.primary {{_ 'save'}}
+
+template(name='accountSettings')
+ ul#account-setting.setting-detail
+ li.smtp-form
+ .title {{_ 'accounts-allowEmailChange'}}
+ .form-group.flex
+ input.form-control#accounts-allowEmailChange(type="radio" name="allowEmailChange" value="true" checked="{{#if allowEmailChange}}checked{{/if}}")
+ span {{_ 'yes'}}
+ input.form-control#accounts-allowEmailChange(type="radio" name="allowEmailChange" value="false" checked="{{#unless allowEmailChange}}checked{{/unless}}")
+ span {{_ 'no'}}
+ li
+ button.js-accounts-save.primary {{_ 'save'}}
diff --git a/client/components/settings/settingBody.js b/client/components/settings/settingBody.js
index f96312a5..a2993426 100644
--- a/client/components/settings/settingBody.js
+++ b/client/components/settings/settingBody.js
@@ -1,5 +1,6 @@
Meteor.subscribe('setting');
Meteor.subscribe('mailServer');
+Meteor.subscribe('accountSettings');
BlazeComponent.extendComponent({
onCreated() {
@@ -7,6 +8,7 @@ BlazeComponent.extendComponent({
this.loading = new ReactiveVar(false);
this.generalSetting = new ReactiveVar(true);
this.emailSetting = new ReactiveVar(false);
+ this.accountSetting = new ReactiveVar(false);
},
setError(error) {
@@ -62,6 +64,7 @@ BlazeComponent.extendComponent({
const targetID = target.data('id');
this.generalSetting.set('registration-setting' === targetID);
this.emailSetting.set('email-setting' === targetID);
+ this.accountSetting.set('account-setting' === targetID);
}
},
@@ -130,3 +133,22 @@ BlazeComponent.extendComponent({
}];
},
}).register('setting');
+
+BlazeComponent.extendComponent({
+ saveAllowEmailChange() {
+ const allowEmailChange = ($('input[name=allowEmailChange]:checked').val() === 'true');
+ AccountSettings.update('accounts-allowEmailChange', {
+ $set: { 'booleanValue': allowEmailChange },
+ });
+ },
+
+ allowEmailChange() {
+ return AccountSettings.findOne('accounts-allowEmailChange').booleanValue;
+ },
+
+ events() {
+ return [{
+ 'click button.js-accounts-save': this.saveAllowEmailChange,
+ }];
+ },
+}).register('accountSettings');
diff --git a/client/components/users/userHeader.jade b/client/components/users/userHeader.jade
index 84ef5a09..f67f82ee 100644
--- a/client/components/users/userHeader.jade
+++ b/client/components/users/userHeader.jade
@@ -36,6 +36,14 @@ template(name="editProfilePopup")
label
| {{_ 'initials'}}
input.js-profile-initials(type="text" value=profile.initials)
+ label
+ | {{_ 'email'}}
+ span.error.hide.email-taken
+ | {{_ 'error-email-taken'}}
+ if allowEmailChange
+ input.js-profile-email(type="email" value="{{emails.[0].address}}")
+ else
+ input.js-profile-email(type="email" value="{{emails.[0].address}}" readonly)
input.primary.wide(type="submit" value="{{_ 'save'}}")
template(name="editNotificationPopup")
diff --git a/client/components/users/userHeader.js b/client/components/users/userHeader.js
index 0580092e..90205ee1 100644
--- a/client/components/users/userHeader.js
+++ b/client/components/users/userHeader.js
@@ -20,18 +20,47 @@ Template.memberMenuPopup.events({
},
});
+Template.editProfilePopup.helpers({
+ allowEmailChange() {
+ return AccountSettings.findOne('accounts-allowEmailChange').booleanValue;
+ },
+});
+
Template.editProfilePopup.events({
submit(evt, tpl) {
evt.preventDefault();
const fullname = tpl.find('.js-profile-fullname').value.trim();
const username = tpl.find('.js-profile-username').value.trim();
const initials = tpl.find('.js-profile-initials').value.trim();
+ const email = tpl.find('.js-profile-email').value.trim();
+ let isChangeUserName = false;
+ let isChangeEmail = false;
Users.update(Meteor.userId(), {$set: {
'profile.fullname': fullname,
'profile.initials': initials,
}});
-
- if (username !== Meteor.user().username) {
+ isChangeUserName = username !== Meteor.user().username;
+ isChangeEmail = email.toLowerCase() !== Meteor.user().emails[0].address.toLowerCase();
+ if (isChangeUserName && isChangeEmail) {
+ Meteor.call('setUsernameAndEmail', username, email.toLowerCase(), function(error) {
+ const usernameMessageElement = tpl.$('.username-taken');
+ const emailMessageElement = tpl.$('.email-taken');
+ if (error) {
+ const errorElement = error.error;
+ if (errorElement === 'username-already-taken') {
+ usernameMessageElement.show();
+ emailMessageElement.hide();
+ } else if (errorElement === 'email-already-taken') {
+ usernameMessageElement.hide();
+ emailMessageElement.show();
+ }
+ } else {
+ usernameMessageElement.hide();
+ emailMessageElement.hide();
+ Popup.back();
+ }
+ });
+ } else if (isChangeUserName) {
Meteor.call('setUsername', username, function(error) {
const messageElement = tpl.$('.username-taken');
if (error) {
@@ -41,6 +70,16 @@ Template.editProfilePopup.events({
Popup.back();
}
});
+ } else if (isChangeEmail) {
+ Meteor.call('setEmail', email.toLowerCase(), function(error) {
+ const messageElement = tpl.$('.email-taken');
+ if (error) {
+ messageElement.show();
+ } else {
+ messageElement.hide();
+ Popup.back();
+ }
+ });
} else Popup.back();
},
});