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 b9ad5d91
authored
Sep 08, 2015
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve error handling on login
1 parent
85589460
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
cli/actions.js
cli/actions.js
View file @
b9ad5d9
...
...
@@ -53,20 +53,24 @@ function login(uri) {
var
tmp
=
url
.
parse
(
uri
);
if
(
!
tmp
.
host
)
tmp
=
url
.
parse
(
'https://'
+
uri
);
var
server
=
'https:
//'
+
tmp
.
host
;
var
server
=
tmp
.
protocol
+
'
//'
+
tmp
.
host
;
console
.
log
(
'Using server'
,
server
);
console
.
log
(
'Using server'
,
server
.
bold
);
var
username
=
readlineSync
.
question
(
'Username: '
,
{
hideEchoBack
:
false
});
var
password
=
readlineSync
.
question
(
'Password: '
,
{
hideEchoBack
:
true
});
superagent
.
get
(
server
+
API
+
'/'
).
query
({
username
:
username
,
password
:
password
}).
end
(
function
(
error
,
result
)
{
if
(
error
&&
error
.
code
===
'ENOTFOUND'
)
{
console
.
log
(
'No such server %s'
.
red
,
server
);
console
.
log
(
'No such server %s'
.
red
,
server
.
bold
);
process
.
exit
(
1
);
}
if
(
error
.
code
)
{
console
.
log
(
'Failed to connect to server %s'
.
red
,
server
.
bold
,
error
.
code
);
process
.
exit
(
1
);
}
if
(
result
.
status
===
401
)
{
console
.
log
(
'Login failed.'
);
console
.
log
(
'Login failed.'
.
red
);
process
.
exit
(
1
);
}
...
...
@@ -78,7 +82,7 @@ function login(uri) {
gQuery
=
{
username
:
username
,
password
:
password
};
console
.
log
(
'
Done
'
.
green
);
console
.
log
(
'
Ok
'
.
green
);
});
}
...
...
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