diff options
author | Johannes Zellner <johannes@cloudron.io> | 2017-02-09 13:16:41 +0100 |
---|---|---|
committer | Johannes Zellner <johannes@cloudron.io> | 2017-02-09 13:16:41 +0100 |
commit | 15397f71b86c50f306e5116f557c9f290b348b1a (patch) | |
tree | db2eb2b15bb8bb12174221c203f54a964791dea8 | |
parent | 8fa082298cfbfd96eaa029d6e60ff5fd8ce65252 (diff) | |
download | Surfer-15397f71b86c50f306e5116f557c9f290b348b1a.tar.gz Surfer-15397f71b86c50f306e5116f557c9f290b348b1a.tar.zst Surfer-15397f71b86c50f306e5116f557c9f290b348b1a.zip |
Add cli logout command
-rw-r--r-- | cli/actions.js | 18 | ||||
-rwxr-xr-x | cli/surfer.js | 4 |
2 files changed, 22 insertions, 0 deletions
diff --git a/cli/actions.js b/cli/actions.js index 45656a6..065e700 100644 --- a/cli/actions.js +++ b/cli/actions.js | |||
@@ -1,6 +1,7 @@ | |||
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | exports.login = login; | 3 | exports.login = login; |
4 | exports.logout = logout; | ||
4 | exports.put = put; | 5 | exports.put = put; |
5 | exports.get = get; | 6 | exports.get = get; |
6 | exports.del = del; | 7 | exports.del = del; |
@@ -92,6 +93,23 @@ function login(uri) { | |||
92 | }); | 93 | }); |
93 | } | 94 | } |
94 | 95 | ||
96 | function logout() { | ||
97 | checkConfig(); | ||
98 | |||
99 | superagent.post(config.server() + '/api/logout').query(gQuery).end(function (error, result) { | ||
100 | if (result && result.statusCode !== 200) console.log('Failed to logout: ' + result.statusCode); | ||
101 | if (error) console.log(error); | ||
102 | |||
103 | // TODO remove at some point, this is just to clear the previous old version values | ||
104 | config.set('username', ''); | ||
105 | config.set('password', ''); | ||
106 | config.set('server', ''); | ||
107 | config.set('accessToken', ''); | ||
108 | |||
109 | console.log('Done'.green); | ||
110 | }); | ||
111 | } | ||
112 | |||
95 | function put(filePath, otherFilePaths, options) { | 113 | function put(filePath, otherFilePaths, options) { |
96 | checkConfig(); | 114 | checkConfig(); |
97 | 115 | ||
diff --git a/cli/surfer.js b/cli/surfer.js index 46e5ba5..ef3ed91 100755 --- a/cli/surfer.js +++ b/cli/surfer.js | |||
@@ -11,6 +11,10 @@ program.command('login <url>') | |||
11 | .description('Login to server') | 11 | .description('Login to server') |
12 | .action(actions.login); | 12 | .action(actions.login); |
13 | 13 | ||
14 | program.command('logout') | ||
15 | .description('Logout from server') | ||
16 | .action(actions.logout); | ||
17 | |||
14 | program.command('put <file> [files...]') | 18 | program.command('put <file> [files...]') |
15 | .option('-a --all', 'Also include hidden files and folders.', false) | 19 | .option('-a --all', 'Also include hidden files and folders.', false) |
16 | .description('Put a file, last argument is destination if provided') | 20 | .description('Put a file, last argument is destination if provided') |