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

SessionLogin => Call SessionManager login function

parent 388a0d28
Branches
Tags
No related merge requests found
import chalk from 'chalk';
import CommanderCommand from '../../CommanderCommand';
import GitlabManager from '../../../managers/GitlabManager';
import inquirer from 'inquirer';
import SessionManager from '../../../managers/SessionManager';
class SessionLoginCommand extends CommanderCommand {
......@@ -9,26 +8,18 @@ class SessionLoginCommand extends CommanderCommand {
protected defineCommand() {
this.command
.description('register to Dojo')
.option('-t, --token <string>', 'personal access token from GitLab with api scope')
.description('login to Dojo')
.option('-c, --cli', 'proceed to the login in headless mode (do not try to open web browser).')
.action(this.commandAction.bind(this));
}
protected async commandAction(options: { token: string }): Promise<void> {
if ( !options.token ) {
options.token = (await inquirer.prompt({
type : 'password',
name : 'token',
message: 'Please enter your gitlab token',
mask : ''
})).token;
}
console.log(chalk.cyan('Please wait while we are testing your Gitlab token...'));
protected async commandAction(options: { cli: boolean }): Promise<void> {
try {
console.log(chalk.cyan('Please wait while we login you into Dojo...'));
await SessionManager.login(options.cli);
} catch ( error ) {
GitlabManager.login(options.token);
await GitlabManager.testToken();
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment