Adds setting to allow/deny own account deletion

pull/2415/head
Marcelo Schmidt 10 years ago
parent d52056e868
commit e483b7c3e2
  1. 1
      i18n/en.i18n.json
  2. 4
      packages/rocketchat-lib/server/methods/deleteUserOwnAccount.js
  3. 1
      packages/rocketchat-lib/server/startup/settings.coffee
  4. 3
      packages/rocketchat-ui-account/account/accountPreferences.coffee
  5. 2
      packages/rocketchat-ui-account/account/accountPreferences.html

@ -7,6 +7,7 @@
"Access_Online_Demo" : "Access the Online Demo",
"Access_Token_URL" : "Access Token URL",
"Accounts" : "Accounts",
"Accounts_AllowDeleteOwnAccount" : "Allow users to delete own account",
"Accounts_AllowedDomainsList" : "Allowed Domains List",
"Accounts_AllowedDomainsList_Description" : "Comma-separated list of allowed domains",
"Accounts_AllowEmailChange" : "Allow E-mail Change",

@ -4,6 +4,10 @@ Meteor.methods({
throw new Meteor.Error('invalid-user', "[methods] deleteUserOwnAccount -> Invalid user");
}
if (!RocketChat.settings.get('Accounts_AllowDeleteOwnAccount')) {
throw new Meteor.Error('not-authorized', "[methods] deleteUserOwnAccount -> Not authorized");
}
const userId = Meteor.userId();
const user = RocketChat.models.Users.findOneById(userId);

@ -3,6 +3,7 @@ if not RocketChat.models.Settings.findOneById 'uniqueID'
RocketChat.models.Settings.createWithIdAndValue 'uniqueID', process.env.DEPLOYMENT_ID or Random.id()
RocketChat.settings.addGroup 'Accounts', ->
@add 'Accounts_AllowDeleteOwnAccount', true, { type: 'boolean', public: true }
@add 'Accounts_AllowUserProfileChange', true, { type: 'boolean', public: true }
@add 'Accounts_AllowUserAvatarChange', true, { type: 'boolean', public: true }
@add 'Accounts_AllowUsernameChange', true, { type: 'boolean', public: true }

@ -1,4 +1,7 @@
Template.accountPreferences.helpers
allowDeleteOwnAccount: ->
return RocketChat.settings.get('Accounts_AllowDeleteOwnAccount')
checked: (property, value, defaultValue) ->
if not Meteor.user()?.settings?.preferences?[property]? and defaultValue is true
currentValue = value

@ -115,9 +115,11 @@
<div class="submit">
<button class="button"><i class="icon-send"></i><span>{{_ "Save_changes"}}</span></button>
</div>
{{#if allowDeleteOwnAccount}}
<div class="delete-account text-right">
<button class="button red"><i class="icon-trash"></i><span>{{_ "Delete_my_account"}}</span></button>
</div>
{{/if}}
</div>
</div>
</section>

Loading…
Cancel
Save