Skip to content
Snippets Groups Projects
Commit 7d2e696b authored by Bradley Hilton's avatar Bradley Hilton Committed by Rodrigo Nascimento
Browse files

Add permission check to the import methods and not just the UI (#6400)

parent 20695fac
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,9 @@ Meteor.methods
if not Meteor.userId()
throw new Meteor.Error 'error-invalid-user', 'Invalid user', { method: 'getImportProgress' }
if not RocketChat.authz.hasPermission(Meteor.userId(), 'run-import')
throw new Meteor.Error('error-action-not-allowed', 'Importing is not allowed', { method: 'setupImporter'});
if Importer.Importers[name]?
return Importer.Importers[name].importerInstance?.getProgress()
else
......
......@@ -3,6 +3,9 @@ Meteor.methods
if not Meteor.userId()
throw new Meteor.Error 'error-invalid-user', 'Invalid user', { method: 'getSelectionData' }
if not RocketChat.authz.hasPermission(Meteor.userId(), 'run-import')
throw new Meteor.Error('error-action-not-allowed', 'Importing is not allowed', { method: 'setupImporter'});
if Importer.Importers[name]?.importerInstance?
progress = Importer.Importers[name].importerInstance.getProgress()
switch progress.step
......
......@@ -6,6 +6,10 @@ Meteor.methods({
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'prepareImport' });
}
if (!RocketChat.authz.hasPermission(Meteor.userId(), 'run-import')) {
throw new Meteor.Error('error-action-not-allowed', 'Importing is not allowed', { method: 'setupImporter'});
}
check(name, String);
check(dataURI, String);
check(fileName, String);
......
......@@ -3,6 +3,9 @@ Meteor.methods
if not Meteor.userId()
throw new Meteor.Error 'error-invalid-user', 'Invalid user', { method: 'restartImport' }
if not RocketChat.authz.hasPermission(Meteor.userId(), 'run-import')
throw new Meteor.Error('error-action-not-allowed', 'Importing is not allowed', { method: 'setupImporter'});
if Importer.Importers[name]?
importer = Importer.Importers[name]
importer.importerInstance.updateProgress Importer.ProgressStep.CANCELLED
......
......@@ -3,6 +3,9 @@ Meteor.methods
if not Meteor.userId()
throw new Meteor.Error 'error-invalid-user', 'Invalid user', { method: 'setupImporter' }
if not RocketChat.authz.hasPermission(Meteor.userId(), 'run-import')
throw new Meteor.Error('error-action-not-allowed', 'Importing is not allowed', { method: 'setupImporter'});
if Importer.Importers[name]?.importer?
importer = Importer.Importers[name]
# If they currently have progress, get it and return the progress.
......
......@@ -4,6 +4,9 @@ Meteor.methods
if not Meteor.userId()
throw new Meteor.Error 'error-invalid-user', 'Invalid user', { method: 'startImport' }
if not RocketChat.authz.hasPermission(Meteor.userId(), 'run-import')
throw new Meteor.Error('error-action-not-allowed', 'Importing is not allowed', { method: 'setupImporter'});
if Importer.Importers[name]?.importerInstance?
usersSelection = input.users.map (user) ->
return new Importer.SelectionUser user.user_id, user.username, user.email, user.is_deleted, user.is_bot, user.do_import
......
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