Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

PUBLIC / surfer-okd

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Settings
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Commit ff4aca50 authored 8 years ago by Johannes Zellner's avatar Johannes Zellner
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

Add optional --username and --password arguments for easier scripting

1 parent ba93623c
Show whitespace changes
Inline Side-by-side
Showing with 10 additions and 4 deletions
  • cli/actions.js
  • cli/surfer.js
cli/actions.js
View file @ff4aca5
...@@ -55,7 +55,7 @@ function collectFiles(filesOrFolders, options) { ...@@ -55,7 +55,7 @@ function collectFiles(filesOrFolders, options) {
return tmp; return tmp;
} }
function login(uri) { function login(uri, options) {
var tmp = url.parse(uri); var tmp = url.parse(uri);
if (!tmp.slashes) tmp = url.parse('https://' + uri); if (!tmp.slashes) tmp = url.parse('https://' + uri);
...@@ -63,8 +63,8 @@ function login(uri) { ...@@ -63,8 +63,8 @@ function login(uri) {
console.log('Using server', server.cyan); console.log('Using server', server.cyan);
var username = readlineSync.question('Username: '); var username = options.username || readlineSync.question('Username: ');
var password = readlineSync.question('Password: ', { hideEchoBack: true, mask: '' }); var password = options.password || readlineSync.question('Password: ', { hideEchoBack: true, mask: '' });
superagent.post(server + '/api/login').send({ username: username, password: password }).end(function (error, result) { superagent.post(server + '/api/login').send({ username: username, password: password }).end(function (error, result) {
if (error && error.code === 'ENOTFOUND') { if (error && error.code === 'ENOTFOUND') {
...@@ -77,7 +77,11 @@ function login(uri) { ...@@ -77,7 +77,11 @@ function login(uri) {
} }
if (result.status !== 201) { if (result.status !== 201) {
console.log('Login failed.\n'.red); console.log('Login failed.\n'.red);
return login(uri);
// remove the password to avoid a login loop
delete options.password;
return login(uri, options);
} }
// TODO remove at some point, this is just to clear the previous old version values // TODO remove at some point, this is just to clear the previous old version values
......
This diff is collapsed. Click to expand it.
cli/surfer.js
View file @ff4aca5
...@@ -9,6 +9,8 @@ program.version(require('../package.json').version); ...@@ -9,6 +9,8 @@ program.version(require('../package.json').version);
program.command('login <url>') program.command('login <url>')
.description('Login to server') .description('Login to server')
.option('--username [username]', 'Username (optional)')
.option('--password [password]', 'Password (optional)')
.action(actions.login); .action(actions.login);
program.command('logout') program.command('logout')
......
This diff is collapsed. Click to expand it.
  • Write
  • Preview
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
  • Please register or sign in to post a comment