Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
PUBLIC
/
surfer-okd
This project
Loading...
Sign in
Toggle navigation
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
Feb 09, 2017
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add optional --username and --password arguments for easier scripting
1 parent
ba93623c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
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) {
return
tmp
;
}
function
login
(
uri
)
{
function
login
(
uri
,
options
)
{
var
tmp
=
url
.
parse
(
uri
);
if
(
!
tmp
.
slashes
)
tmp
=
url
.
parse
(
'https://'
+
uri
);
...
...
@@ -63,8 +63,8 @@ function login(uri) {
console
.
log
(
'Using server'
,
server
.
cyan
);
var
username
=
readlineSync
.
question
(
'Username: '
);
var
password
=
readlineSync
.
question
(
'Password: '
,
{
hideEchoBack
:
true
,
mask
:
''
});
var
username
=
options
.
username
||
readlineSync
.
question
(
'Username: '
);
var
password
=
options
.
password
||
readlineSync
.
question
(
'Password: '
,
{
hideEchoBack
:
true
,
mask
:
''
});
superagent
.
post
(
server
+
'/api/login'
).
send
({
username
:
username
,
password
:
password
}).
end
(
function
(
error
,
result
)
{
if
(
error
&&
error
.
code
===
'ENOTFOUND'
)
{
...
...
@@ -77,7 +77,11 @@ function login(uri) {
}
if
(
result
.
status
!==
201
)
{
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
...
...
cli/surfer.js
View file @
ff4aca5
...
...
@@ -9,6 +9,8 @@ program.version(require('../package.json').version);
program
.
command
(
'login <url>'
)
.
description
(
'Login to server'
)
.
option
(
'--username [username]'
,
'Username (optional)'
)
.
option
(
'--password [password]'
,
'Password (optional)'
)
.
action
(
actions
.
login
);
program
.
command
(
'logout'
)
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment