Skip to content
Snippets Groups Projects
Commit 95ffba7e authored by michael.minelli's avatar michael.minelli
Browse files

EnonceCreate => Add template access check

parent 85e27950
No related branches found
No related tags found
No related merge requests found
import CommanderCommand from '../CommanderCommand';
import GitlabUser from '../../models/GitlabUser';
import chalk from 'chalk';
import ora from 'ora';
import GitlabManager from '../../managers/GitlabManager';
import Config from '../../config/Config';
import SessionManager from '../../managers/SessionManager';
import GitlabUser from '../../shared/types/Gitlab/GitlabUser';
import DojoBackendManager from '../../managers/DojoBackendManager';
import Toolbox from '../../shared/Toolbox';
class EnonceCreateCommand extends CommanderCommand {
......@@ -28,6 +29,7 @@ class EnonceCreateCommand extends CommanderCommand {
.requiredOption('-n, --name <name>', 'name of the enonce.')
.option('-i, --members_id <ids...>', 'list of members ids (teaching staff) to add to the repository.')
.option('-m, --members_username <usernames...>', 'list of members username (teaching staff) to add to the repository.')
.option('-t, --template <string>', 'id or url of the template (http(s) and ssh urls are possible).')
.action(this.commandAction.bind(this));
}
......@@ -101,8 +103,21 @@ class EnonceCreateCommand extends CommanderCommand {
if ( !members ) {
return;
}
if ( options.template ) {
let templateIdOrNamespace: string = options.template;
if ( Number.isNaN(Number(templateIdOrNamespace)) ) {
templateIdOrNamespace = encodeURIComponent(Toolbox.urlToPath(templateIdOrNamespace));
}
if ( !await DojoBackendManager.checkTemplateAccess(templateIdOrNamespace) ) {
return;
}
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment