Browse Source

Merge pull request #1627 from thiagofernando/devel

Includes possibility to block username change
Lauri Ojansivu 7 years ago
parent
commit
0b9328a1be

+ 9 - 1
client/components/settings/settingBody.jade

@@ -94,13 +94,21 @@ template(name='email')
 
 template(name='accountSettings')
   ul#account-setting.setting-detail
-    li.smtp-form
+    li.accounts-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
+    li.accounts-form
+      .title {{_ 'accounts-allowUserNameChange'}}
+      .form-group.flex
+        input.form-control#accounts-allowUserNameChange(type="radio" name="allowUserNameChange" value="true" checked="{{#if allowUserNameChange}}checked{{/if}}")
+        span {{_ 'yes'}}
+        input.form-control#accounts-allowUserNameChange(type="radio" name="allowUserNameChange" value="false" checked="{{#unless allowUserNameChange}}checked{{/unless}}")
+        span {{_ 'no'}}
     li
       button.js-accounts-save.primary {{_ 'save'}}
 

+ 40 - 27
client/components/settings/settingBody.js

@@ -23,7 +23,7 @@ BlazeComponent.extendComponent({
 
   checkField(selector) {
     const value = $(selector).val();
-    if(!value || value.trim() === ''){
+    if (!value || value.trim() === '') {
       $(selector).parents('li.smtp-form').addClass('has-error');
       throw Error('blank field');
     } else {
@@ -31,7 +31,7 @@ BlazeComponent.extendComponent({
     }
   },
 
-  currentSetting(){
+  currentSetting() {
     return Settings.findOne();
   },
 
@@ -44,23 +44,23 @@ BlazeComponent.extendComponent({
       sort: ['title'],
     });
   },
-  toggleRegistration(){
+  toggleRegistration() {
     this.setLoading(true);
     const registrationClosed = this.currentSetting().disableRegistration;
-    Settings.update(Settings.findOne()._id, {$set:{disableRegistration: !registrationClosed}});
+    Settings.update(Settings.findOne()._id, {$set: {disableRegistration: !registrationClosed}});
     this.setLoading(false);
-    if(registrationClosed){
+    if (registrationClosed) {
       $('.invite-people').slideUp();
-    }else{
+    } else {
       $('.invite-people').slideDown();
     }
   },
-  toggleTLS(){
+  toggleTLS() {
     $('#mail-server-tls').toggleClass('is-checked');
   },
-  switchMenu(event){
+  switchMenu(event) {
     const target = $(event.target);
-    if(!target.hasClass('active')){
+    if (!target.hasClass('active')) {
       $('.side-menu li.active').removeClass('active');
       target.parent().addClass('active');
       const targetID = target.data('id');
@@ -71,9 +71,9 @@ BlazeComponent.extendComponent({
     }
   },
 
-  checkBoard(event){
+  checkBoard(event) {
     let target = $(event.target);
-    if(!target.hasClass('js-toggle-board-choose')){
+    if (!target.hasClass('js-toggle-board-choose')) {
       target = target.parent();
     }
     const checkboxId = target.attr('id');
@@ -81,7 +81,7 @@ BlazeComponent.extendComponent({
     $(`#${checkboxId}`).toggleClass('is-checked');
   },
 
-  inviteThroughEmail(){
+  inviteThroughEmail() {
     const emails = $('#email-to-invite').val().trim().split('\n').join(',').split(',');
     const boardsToInvite = [];
     $('.js-toggle-board-choose .materialCheckBox.is-checked').each(function () {
@@ -104,19 +104,23 @@ BlazeComponent.extendComponent({
     }
   },
 
-  saveMailServerInfo(){
+  saveMailServerInfo() {
     this.setLoading(true);
     $('li').removeClass('has-error');
 
-    try{
+    try {
       const host = this.checkField('#mail-server-host');
       const port = this.checkField('#mail-server-port');
       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.enableTLS': tls, 'mailServer.from': from}});
+      Settings.update(Settings.findOne()._id, {
+        $set: {
+          'mailServer.host': host, 'mailServer.port': port, 'mailServer.username': username,
+          'mailServer.password': password, 'mailServer.enableTLS': tls, 'mailServer.from': from,
+        },
+      });
     } catch (e) {
       return;
     } finally {
@@ -136,11 +140,12 @@ BlazeComponent.extendComponent({
         const message = `${TAPi18n.__(err.error)}\n${reason}`;
         console.log(message, err);
         alert(message);
-      }  /* eslint-enable no-console */
+      }
+      /* eslint-enable no-console */
     });
   },
 
-  events(){
+  events() {
     return [{
       'click a.js-toggle-registration': this.toggleRegistration,
       'click a.js-toggle-tls': this.toggleTLS,
@@ -154,20 +159,28 @@ BlazeComponent.extendComponent({
 }).register('setting');
 
 BlazeComponent.extendComponent({
-  saveAllowEmailChange() {
+
+  saveAccountsChange() {
     const allowEmailChange = ($('input[name=allowEmailChange]:checked').val() === 'true');
+    const allowUserNameChange = ($('input[name=allowUserNameChange]:checked').val() === 'true');
     AccountSettings.update('accounts-allowEmailChange', {
-      $set: { 'booleanValue': allowEmailChange },
+      $set: {'booleanValue': allowEmailChange},
+    });
+    AccountSettings.update('accounts-allowUserNameChange', {
+      $set: {'booleanValue': allowUserNameChange},
     });
   },
 
   allowEmailChange() {
     return AccountSettings.findOne('accounts-allowEmailChange').booleanValue;
   },
+  allowUserNameChange() {
+    return AccountSettings.findOne('accounts-allowUserNameChange').booleanValue;
+  },
 
   events() {
     return [{
-      'click button.js-accounts-save': this.saveAllowEmailChange,
+      'click button.js-accounts-save': this.saveAccountsChange,
     }];
   },
 }).register('accountSettings');
@@ -181,27 +194,27 @@ BlazeComponent.extendComponent({
     this.loading.set(w);
   },
 
-  currentSetting(){
+  currentSetting() {
     return Announcements.findOne();
   },
 
   saveMessage() {
     const message = $('#admin-announcement').val().trim();
     Announcements.update(Announcements.findOne()._id, {
-      $set: { 'body': message },
+      $set: {'body': message},
     });
   },
 
-  toggleActive(){
+  toggleActive() {
     this.setLoading(true);
     const isActive = this.currentSetting().enabled;
     Announcements.update(Announcements.findOne()._id, {
-      $set:{ 'enabled': !isActive},
+      $set: {'enabled': !isActive},
     });
     this.setLoading(false);
-    if(isActive){
+    if (isActive) {
       $('.admin-announcement').slideUp();
-    }else{
+    } else {
       $('.admin-announcement').slideDown();
     }
   },

+ 4 - 1
client/components/users/userHeader.jade

@@ -33,7 +33,10 @@ template(name="editProfilePopup")
       | {{_ 'username'}}
       span.error.hide.username-taken
         | {{_ 'error-username-taken'}}
-      input.js-profile-username(type="text" value=username)
+      if allowUserNameChange
+        input.js-profile-username(type="text" value=username)
+      else
+        input.js-profile-username(type="text" value=username readonly)
     label
       | {{_ 'initials'}}
       input.js-profile-initials(type="text" value=profile.initials)

+ 3 - 0
client/components/users/userHeader.js

@@ -24,6 +24,9 @@ Template.editProfilePopup.helpers({
   allowEmailChange() {
     return AccountSettings.findOne('accounts-allowEmailChange').booleanValue;
   },
+  allowUserNameChange() {
+    return AccountSettings.findOne('accounts-allowUserNameChange').booleanValue;
+  },
 });
 
 Template.editProfilePopup.events({

+ 1 - 1
i18n/ar.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/bg.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/br.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/ca.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/cs.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Končí v",
     "editCardReceivedDatePopup-title": "Změnit datum přijetí",
     "editCardEndDatePopup-title": "Změnit datum konce"
-}
+}

+ 1 - 1
i18n/de.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Endet am",
     "editCardReceivedDatePopup-title": "Empfangsdatum ändern",
     "editCardEndDatePopup-title": "Enddatum ändern"
-}
+}

+ 1 - 1
i18n/el.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/en-GB.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 0
i18n/en.i18n.json

@@ -434,6 +434,7 @@
     "no": "No",
     "accounts": "Accounts",
     "accounts-allowEmailChange": "Allow Email Change",
+    "accounts-allowUserNameChange": "Allow Username Change",
     "createdAt": "Created at",
     "verified": "Verified",
     "active": "Active",

+ 1 - 1
i18n/eo.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/es-AR.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Termina en",
     "editCardReceivedDatePopup-title": "Cambiar fecha de recepción",
     "editCardEndDatePopup-title": "Cambiar fecha de término"
-}
+}

+ 1 - 1
i18n/es.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Finalizado el",
     "editCardReceivedDatePopup-title": "Cambiar la fecha de recepción",
     "editCardEndDatePopup-title": "Cambiar la fecha de finalización"
-}
+}

+ 1 - 1
i18n/eu.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/fa.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "پایان در",
     "editCardReceivedDatePopup-title": "تغییر تاریخ رسید",
     "editCardEndDatePopup-title": "تغییر تاریخ پایان"
-}
+}

+ 1 - 1
i18n/fi.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Loppuu",
     "editCardReceivedDatePopup-title": "Vaihda vastaanottamispäivää",
     "editCardEndDatePopup-title": "Vaihda loppumispäivää"
-}
+}

+ 1 - 1
i18n/fr.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Se termine le",
     "editCardReceivedDatePopup-title": "Changer la date de réception",
     "editCardEndDatePopup-title": "Changer la date de fin"
-}
+}

+ 1 - 1
i18n/gl.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/he.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/hu.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/hy.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/id.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/ig.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/it.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Termina il",
     "editCardReceivedDatePopup-title": "Cambia data ricezione",
     "editCardEndDatePopup-title": "Cambia data finale"
-}
+}

+ 1 - 1
i18n/ja.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/ko.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/lv.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/mn.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/nb.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/nl.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/pl.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/pt-BR.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/pt.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/ro.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/ru.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Завершится до",
     "editCardReceivedDatePopup-title": "Изменить дату получения",
     "editCardEndDatePopup-title": "Изменить дату завершения"
-}
+}

+ 1 - 1
i18n/sr.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/sv.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Ändra mottagningsdatum",
     "editCardEndDatePopup-title": "Ändra slutdatum"
-}
+}

+ 1 - 1
i18n/ta.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/th.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/tr.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Bitiş zamanı",
     "editCardReceivedDatePopup-title": "Giriş tarihini değiştir",
     "editCardEndDatePopup-title": "Bitiş tarihini değiştir"
-}
+}

+ 1 - 1
i18n/uk.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/vi.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 1 - 1
i18n/zh-CN.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "终止于",
     "editCardReceivedDatePopup-title": "修改接收日期",
     "editCardEndDatePopup-title": "修改终止日期"
-}
+}

+ 1 - 1
i18n/zh-TW.i18n.json

@@ -443,4 +443,4 @@
     "card-end-on": "Ends on",
     "editCardReceivedDatePopup-title": "Change received date",
     "editCardEndDatePopup-title": "Change end date"
-}
+}

+ 7 - 1
models/accountSettings.js

@@ -23,11 +23,17 @@ AccountSettings.allow({
 
 if (Meteor.isServer) {
   Meteor.startup(() => {
-    AccountSettings.upsert({ _id: 'accounts-allowEmailChange' }, {
+    AccountSettings.upsert({_id: 'accounts-allowEmailChange'}, {
       $setOnInsert: {
         booleanValue: false,
         sort: 0,
       },
     });
+    AccountSettings.upsert({_id: 'accounts-allowUserNameChange'}, {
+      $setOnInsert: {
+        booleanValue: false,
+        sort: 1,
+      },
+    });
   });
 }