Implemented AllowUserAvatarChange and Accounts_AllowUserProfileChange account settings

pull/1301/head
Rafael Caferati 10 years ago
parent 3cdfa8ec4a
commit ac60580fc3
  1. 6
      client/views/account/accountFlex.coffee
  2. 9
      client/views/account/accountFlex.html
  3. 2
      client/views/account/accountProfile.coffee
  4. 2
      client/views/account/avatar/prompt.coffee
  5. 2
      packages/rocketchat-lib/settings/server/startup.coffee
  6. 3
      server/methods/resetAvatar.coffee
  7. 3
      server/methods/saveUserProfile.coffee
  8. 5
      server/methods/setAvatarFromService.coffee

@ -13,3 +13,9 @@ Template.accountFlex.events
'click .account-link': ->
menu.close()
Template.accountFlex.helpers
allowUserProfileChange: ->
return RocketChat.settings.get("Accounts_AllowUserProfileChange")
allowUserAvatarChange: ->
return RocketChat.settings.get("Accounts_AllowUserAvatarChange")

@ -9,10 +9,15 @@
<ul>
<li>
<a href="{{pathFor 'account' group='preferences'}}" class="account-link">{{_ "Preferences"}}</a>
<a href="{{pathFor 'account' group='profile'}}" class="account-link">{{_ "Profile"}}</a>
{{#if allowUserProfileChange}}
<a href="{{pathFor 'account' group='profile'}}" class="account-link">{{_ "Profile"}}</a>
{{/if}}
{{!-- <a href="{{pathFor 'account' group='account'}}" class="account-link">{{_ "Account_Settings"}}</a> --}}
{{!-- <a href="{{pathFor 'account' group='notification'}}" class="account-link">{{_ "Notification"}}</a> --}}
<a href="{{pathFor 'changeAvatar'}}" class="account-link">{{_ "Change_avatar"}}</a> {{!-- move this to profile --}}
{{#if allowUserProfileChange}}
<a href="{{pathFor 'changeAvatar'}}" class="account-link">{{_ "Change_avatar"}}</a>
{{/if}}
{{!-- move this to profile --}}
</li>
</ul>
</div>

@ -98,6 +98,8 @@ Template.accountProfile.onCreated ->
Template.accountProfile.onRendered ->
Tracker.afterFlush ->
# this should throw an error-template
window.location.href = "/" if !RocketChat.settings.get("Accounts_AllowUserAvatarChange")
SideNav.setFlex "accountFlex"
SideNav.openFlex()

@ -14,6 +14,8 @@ Template.avatarPrompt.onCreated ->
Template.avatarPrompt.onRendered ->
Tracker.afterFlush ->
# this should throw an error-template
# window.location.href = "/" if !RocketChat.settings.get("Accounts_AllowUserProfileChange")
SideNav.setFlex "accountFlex"
SideNav.openFlex()

@ -35,6 +35,8 @@ RocketChat.settings.add 'Accounts_OAuth_Twitter', false, { type: 'boolean', grou
RocketChat.settings.add 'Accounts_OAuth_Twitter_id', '', { type: 'string', group: 'Accounts', section: 'Twitter' }
RocketChat.settings.add 'Accounts_OAuth_Twitter_secret', '', { type: 'string', group: 'Accounts', section: 'Twitter' }
RocketChat.settings.add 'Accounts_AllowUserProfileChange', false, { type: 'boolean', group: 'Accounts', section: 'General', public: true }
RocketChat.settings.add 'Accounts_AllowUserAvatarChange', false, { type: 'boolean', group: 'Accounts', section: 'General', public: true }
RocketChat.settings.add 'Accounts_AllowUsernameChange', true, { type: 'boolean', group: 'Accounts', section: 'General', public: true }
RocketChat.settings.add 'Accounts_AllowPasswordChange', true, { type: 'boolean', group: 'Accounts', section: 'General', public: true }

@ -3,6 +3,9 @@ Meteor.methods
unless Meteor.userId()
throw new Meteor.Error(403, "[methods] resetAvatar -> Invalid user")
unless RocketChat.settings.get("Accounts_AllowUserAvatarChange")
throw new Meteor.Error(403, "[methods] resetAvatar -> Invalid access")
console.log '[methods] resetAvatar -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments
user = Meteor.user()

@ -1,5 +1,8 @@
Meteor.methods
saveUserProfile: (settings) ->
unless RocketChat.settings.get("Accounts_AllowUserProfileChange")
throw new Meteor.Error(403, "[methods] resetAvatar -> Invalid access")
if Meteor.userId()
if settings.language?
RocketChat.models.Users.setLanguage Meteor.userId(), settings.language

@ -1,8 +1,11 @@
Meteor.methods
setAvatarFromService: (dataURI, contentType, service) ->
if not Meteor.userId()
unless Meteor.userId()
throw new Meteor.Error('invalid-user', "[methods] setAvatarFromService -> Invalid user")
unless RocketChat.settings.get("Accounts_AllowUserAvatarChange")
throw new Meteor.Error(403, "[methods] resetAvatar -> Invalid access")
console.log '[methods] setAvatarFromService -> '.green, 'userId:', Meteor.userId(), 'contentType:', contentType, 'service:', service
user = Meteor.user()

Loading…
Cancel
Save