Skip to content

Commit 70f5f79

Browse files
Replaced old .admin is true by RocketChat.authz.hasRole(Meteor.userId(), 'admin')
1 parent a590758 commit 70f5f79

File tree

7 files changed

+12
-13
lines changed

7 files changed

+12
-13
lines changed

client/views/admin/users/adminInviteUser.coffee

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
Template.adminInviteUser.helpers
22
isAdmin: ->
3-
console.log 'isAdmin', Meteor.user().admin is true
4-
return Meteor.user().admin is true
3+
return RocketChat.authz.hasRole(Meteor.userId(), 'admin')
54
emailEnabled: ->
65
console.log 'emailEnabled', RocketChat.settings.get('MAIL_URL') or (RocketChat.settings.get('SMTP_Host') and RocketChat.settings.get('SMTP_Username') and RocketChat.settings.get('SMTP_Password'))
76
return RocketChat.settings.get('MAIL_URL') or (RocketChat.settings.get('SMTP_Host') and RocketChat.settings.get('SMTP_Username') and RocketChat.settings.get('SMTP_Password'))
87
inviteEmails: ->
98
return Template.instance().inviteEmails.get()
109

11-
Template.adminInviteUser.events
10+
Template.adminInviteUser.events
1211
'click .send': (e, instance) ->
1312
emails = $('#inviteEmails').val().split /[\s,;]/
1413
rfcMailPattern = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/

client/views/admin/users/adminUsers.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Template.adminUsers.helpers
2323
return RocketChat.TabBar.getData()
2424

2525
adminClass: ->
26-
return 'admin' if Meteor.user()?.admin is true
26+
return 'admin' if RocketChat.authz.hasRole(Meteor.userId(), 'admin')
2727

2828
Template.adminUsers.onCreated ->
2929
instance = @
@@ -56,7 +56,7 @@ Template.adminUsers.onCreated ->
5656
query = { $or: [ { username: filterReg }, { name: filterReg }, { "emails.address": filterReg } ] }
5757
else
5858
query = {}
59-
59+
6060
return Meteor.users.find(query, { limit: instance.limit?.get(), sort: { username: 1, name: 1 } }).fetch()
6161

6262
Template.adminUsers.onRendered ->

client/views/app/room.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ Template.room.helpers
229229
return RocketChat.TabBar.getData()
230230

231231
adminClass: ->
232-
return 'admin' if Meteor.user()?.admin is true
232+
return 'admin' if RocketChat.authz.hasRole(Meteor.userId(), 'admin')
233233

234234
Template.room.events
235235
"touchstart .message": (e, t) ->

packages/rocketchat-lib/server/methods/sendInvitationEmail.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ Meteor.methods
33
if not Meteor.userId()
44
throw new Meteor.Error 'invalid-user', "[methods] sendInvitationEmail -> Invalid user"
55

6-
unless Meteor.user()?.admin is true
6+
unless RocketChat.authz.hasRole(Meteor.userId(), 'admin')
77
throw new Meteor.Error 'not-authorized', '[methods] sendInvitationEmail -> Not authorized'
88

99
rfcMailPattern = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
1010
validEmails = _.compact _.map emails, (email) -> return email if rfcMailPattern.test email
11-
11+
1212
for email in validEmails
1313
@unblock()
14-
14+
1515
Email.send
1616
to: email
1717
from: RocketChat.settings.get 'From_Email'
1818
subject: RocketChat.settings.get 'Invitation_Subject'
1919
html: RocketChat.settings.get 'Invitation_HTML'
2020

2121

22-
return validEmails
22+
return validEmails

server/lib/cordova.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Meteor.startup ->
1010
Push.enabled = true
1111
Push.allow
1212
send: (userId, notification) ->
13-
return Meteor.users.findOne({_id: userId})?.admin is true
13+
return RocketChat.authz.hasRole(userId, 'admin')
1414

1515
Push.Configure
1616
apn:

server/methods/archiveRoom.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Meteor.methods
77

88
room = ChatRoom.findOne rid
99

10-
if room.u? and room.u._id is Meteor.userId() or Meteor.user().admin?
10+
if room.u? and room.u._id is Meteor.userId() or RocketChat.authz.hasRole(Meteor.userId(), 'admin')
1111
update =
1212
$set:
1313
archived: true

server/methods/unarchiveRoom.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Meteor.methods
77

88
room = ChatRoom.findOne rid
99

10-
if room.u? and room.u._id is Meteor.userId() or Meteor.user().admin?
10+
if room.u? and room.u._id is Meteor.userId() or RocketChat.authz.hasRole(Meteor.userId(), 'admin')
1111
update =
1212
$set:
1313
archived: false

0 commit comments

Comments
 (0)