Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
Rocket.Chat.Apps-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
RocketChat
Rocket.Chat.Apps-cli
Commits
dfd63284
Unverified
Commit
dfd63284
authored
Oct 01, 2019
by
Bradley Hilton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a login command
parent
623da2d6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
src/commands/login.ts
src/commands/login.ts
+34
-0
No files found.
src/commands/login.ts
0 → 100644
View file @
dfd63284
import
{
Command
,
flags
}
from
'
@oclif/command
'
;
import
chalk
from
'
chalk
'
;
import
cli
from
'
cli-ux
'
;
import
*
as
inquirer
from
'
inquirer
'
;
import
{
CloudAuth
}
from
'
../misc/cloudAuth
'
;
export
default
class
Login
extends
Command
{
public
static
description
=
'
steps through the process to log in with Rocket.Chat Cloud
'
;
public
static
flags
=
{
help
:
flags
.
help
({
char
:
'
h
'
}),
};
public
async
run
()
{
inquirer
.
registerPrompt
(
'
checkbox-plus
'
,
require
(
'
inquirer-checkbox-plus-prompt
'
));
const
cloudAuth
=
new
CloudAuth
();
const
hasToken
=
await
cloudAuth
.
hasToken
();
if
(
hasToken
)
{
await
cloudAuth
.
getToken
();
cli
.
log
(
chalk
.
green
(
'
you are already logged in!
'
));
}
else
{
try
{
cli
.
log
(
chalk
.
green
(
'
*
'
)
+
'
'
+
chalk
.
gray
(
'
waiting for authorization...
'
));
await
cloudAuth
.
executeAuthFlow
();
cli
.
action
.
stop
(
'
success!
'
);
}
catch
(
e
)
{
cli
.
action
.
stop
(
'
failure to authenticate.
'
);
return
;
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment