Skip to content
Snippets Groups Projects
Commit 7cac1c4b authored by Diego Sampaio's avatar Diego Sampaio
Browse files

removed all console.logs from publishes and methods

parent 626a100b
No related branches found
No related tags found
No related merge requests found
Showing
with 4 additions and 37 deletions
RocketChat.authz.addUsersToRoles = (userIds, roleNames, scope ) ->
console.log '[methods] addUserToRoles -> '.green, 'arguments:', arguments
if not userIds or not roleNames
return false
......
RocketChat.authz.getRolesForUser = (userId, scope) ->
console.log '[methods] getRolesForUser -> '.green, 'arguments:', arguments
# returns roles for the given scope as well as the global scope
unless scope
scope = Roles.GLOBAL_GROUP
return Roles.getRolesForUser(userId, scope)
\ No newline at end of file
return Roles.getRolesForUser(userId, scope)
RocketChat.authz.hasPermission = (userId, permissionId, scope) ->
console.log '[methods] hasPermission -> '.green, 'arguments:', arguments
# get user's roles
roles = RocketChat.authz.getRolesForUser(userId, scope)
......@@ -9,4 +7,4 @@ RocketChat.authz.hasPermission = (userId, permissionId, scope) ->
for role in roles
permissions = permissions.concat( RocketChat.authz.getPermissionsForRole( role ))
# may contain duplicate, but doesn't matter
return permissionId in permissions
\ No newline at end of file
return permissionId in permissions
RocketChat.authz.hasRole = (userId, roleName, scope) ->
console.log '[methods] hasRoles -> '.green, 'arguments:', arguments
# per alanning:roles, returns true if user is in ANY roles
return Roles.userIsInRole(userId, [roleName], scope)
\ No newline at end of file
return Roles.userIsInRole(userId, [roleName], scope)
RocketChat.authz.removeUsersFromRoles = (userIds, roleNames, scope ) ->
console.log '[methods] removeUsersFromRoles -> '.green, 'arguments:', arguments
if not userIds or not roleNames
return false
......@@ -23,4 +22,4 @@ RocketChat.authz.removeUsersFromRoles = (userIds, roleNames, scope ) ->
Roles.removeUsersFromRoles( userIds, roleNames, scope)
return true
\ No newline at end of file
return true
......@@ -3,6 +3,4 @@ Meteor.methods
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
throw new Meteor.Error "not-authorized"
console.log '[methods] authorization:addPermissionToRole -> '.green, 'arguments:', arguments
RocketChat.models.Permissions.addRole permission, role
......@@ -3,8 +3,6 @@ Meteor.methods
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
throw new Meteor.Error "not-authorized"
console.log('[methods] authorization:addUserToRole -> '.green, 'arguments:', arguments);
if not roleName or not _.isString(roleName) or not username or not _.isString(username)
throw new Meteor.Error 'invalid-arguments'
......
......@@ -3,8 +3,6 @@ Meteor.methods
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
throw new Meteor.Error "not-authorized"
console.log '[methods] authorization:deleteRole -> '.green, 'arguments:', arguments
role = Meteor.roles.findOne _id
if role.protected
......
......@@ -3,6 +3,4 @@ Meteor.methods
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
throw new Meteor.Error "not-authorized"
console.log '[methods] authorization:removeRoleFromPermission -> '.green, 'arguments:', arguments
RocketChat.models.Permissions.removeRole permission, role
......@@ -3,8 +3,6 @@ Meteor.methods
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
throw new Meteor.Error "not-authorized"
console.log('[methods] authorization:removeUserFromRole -> '.green, 'arguments:', arguments);
if not roleName or not _.isString(roleName) or not username or not _.isString(username)
throw new Meteor.Error 'invalid-arguments'
......
......@@ -3,8 +3,6 @@ Meteor.methods
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
throw new Meteor.Error "not-authorized"
console.log '[methods] authorization:saveRole -> '.green, 'arguments:', arguments
saveData =
description: roleData.description
......
Meteor.publish 'permissions', ->
console.log '[publish] permissions'.green
return RocketChat.models.Permissions.find {}
Meteor.methods
saveRoomSettings: (rid, settings) ->
console.log '[method] saveRoomSettings'.green, rid, settings
unless Match.test rid, String
throw new Meteor.Error 'invalid-rid'
......
......@@ -3,8 +3,6 @@ Meteor.methods
if not Meteor.userId()
throw new Meteor.Error('invalid-user', "[methods] addOAuthService -> Invalid user")
console.log '[methods] addOAuthService -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments
unless RocketChat.authz.hasPermission( Meteor.userId(), 'add-oauth-service') is true
throw new Meteor.Error 'not-authorized', '[methods] addOAuthService -> Not authorized'
......
Meteor.methods
checkRegistrationSecretURL: (hash) ->
console.log '[method] checkRegistrationSecretURL'.green, hash
return hash is RocketChat.settings.get 'Accounts_RegistrationForm_SecretURL'
......@@ -3,8 +3,6 @@ Meteor.methods
if not Meteor.userId()
throw new Meteor.Error('invalid-user', "[methods] joinDefaultChannels -> Invalid user")
console.log '[methods] joinDefaultChannels -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments
user = Meteor.user()
RocketChat.callbacks.run 'beforeJoinDefaultChannels', user
......
......@@ -3,8 +3,6 @@ Meteor.methods
if not Meteor.userId()
throw new Meteor.Error('invalid-user', "[methods] addOAuthService -> Invalid user")
console.log '[methods] addOAuthService -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments
unless RocketChat.authz.hasPermission( Meteor.userId(), 'add-oauth-service') is true
throw new Meteor.Error 'not-authorized', '[methods] addOAuthService -> Not authorized'
......
......@@ -6,8 +6,6 @@ Meteor.methods
unless RocketChat.authz.hasRole Meteor.userId(), 'robot'
throw new Meteor.Error 'unauthorized', '[methods] robot.modelCall -> Unauthorized'
console.log '[method] robot.modelCall'.green, arguments
unless _.isFunction RocketChat.models[model]?[method]
throw new Meteor.Error 'invalid-method', '[methods] robot.modelCall -> Invalid method'
......
Meteor.methods
saveSetting: (_id, value) ->
console.log '[method] saveSetting', _id, value
if Meteor.userId()?
user = Meteor.users.findOne Meteor.userId()
......
......@@ -6,8 +6,6 @@ Meteor.methods
if not Meteor.userId()
throw new Meteor.Error('invalid-user', "[methods] sendMessage -> Invalid user")
console.log '[methods] sendMessage -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments
user = RocketChat.models.Users.findOneById Meteor.userId(), fields: username: 1
room = Meteor.call 'canAccessRoom', message.rid, user._id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment