Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
f0fc5a78
Unverified
Commit
f0fc5a78
authored
8 years ago
by
Marcelo Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
Limit calling addUserToRoom to users in room and with permission.
parent
d5a2fe28
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/rocketchat-slashcommands-invite/server.coffee
+1
-1
1 addition, 1 deletion
packages/rocketchat-slashcommands-invite/server.coffee
server/methods/addUserToRoom.coffee
+8
-5
8 additions, 5 deletions
server/methods/addUserToRoom.coffee
with
9 additions
and
6 deletions
packages/rocketchat-slashcommands-invite/server.coffee
+
1
−
1
View file @
f0fc5a78
...
...
@@ -54,7 +54,7 @@ class Invite
_id
:
Random
.
id
()
rid
:
item
.
rid
ts
:
new
Date
msg
:
e
.
error
msg
:
TAPi18n
.
__
(
e
.
error
,
null
,
currentUser
.
language
)
}
return
...
...
This diff is collapsed.
Click to expand it.
server/methods/addUserToRoom.coffee
+
8
−
5
View file @
f0fc5a78
...
...
@@ -2,19 +2,22 @@ Meteor.methods
addUserToRoom
:
(
data
)
->
fromId
=
Meteor
.
userId
()
unless
Match
.
test
data
?
.
rid
,
String
throw
new
Meteor
.
Error
'error-invalid-room'
,
'Invalid room'
,
{
method
:
addUserToRoom
}
throw
new
Meteor
.
Error
'error-invalid-room'
,
'Invalid room'
,
{
method
:
'
addUserToRoom
'
}
unless
Match
.
test
data
?
.
username
,
String
throw
new
Meteor
.
Error
'error-invalid-username'
,
'Invalid username'
,
{
method
:
addUserToRoom
}
throw
new
Meteor
.
Error
'error-invalid-username'
,
'Invalid username'
,
{
method
:
'
addUserToRoom
'
}
room
=
RocketChat
.
models
.
Rooms
.
findOneById
data
.
rid
if
room
.
usernames
.
indexOf
(
Meteor
.
user
().
username
)
is
-
1
throw
new
Meteor
.
Error
'error-not-allowed'
,
'Not allowed'
,
{
method
:
'addUserToRoom'
}
# if room.username isnt Meteor.user().username and room.t is 'c'
if
room
.
t
is
'c'
and
not
RocketChat
.
authz
.
hasPermission
(
fromId
,
'add-user-to-room'
,
room
.
_id
)
throw
new
Meteor
.
Error
'error-not-allowed'
,
'Not allowed'
,
{
method
:
addUserToRoom
}
if
RocketChat
.
authz
.
hasPermission
(
fromId
,
'add-user-to-room'
,
room
.
_id
)
throw
new
Meteor
.
Error
'error-not-allowed'
,
'Not allowed'
,
{
method
:
'
addUserToRoom
'
}
if
room
.
t
is
'd'
throw
new
Meteor
.
Error
'error-cant-invite-for-direct-room'
,
'Can
\'
t invite user to direct rooms'
,
{
method
:
addUserToRoom
}
throw
new
Meteor
.
Error
'error-cant-invite-for-direct-room'
,
'Can
\'
t invite user to direct rooms'
,
{
method
:
'
addUserToRoom
'
}
# verify if user is already in room
if
room
.
usernames
.
indexOf
(
data
.
username
)
isnt
-
1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment