From d15ef8e215b8da97607add7a50a372a8d17f96b3 Mon Sep 17 00:00:00 2001 From: Muh-Hasan Date: Sun, 29 Aug 2021 00:59:02 +0500 Subject: [PATCH] object structure updated & added new values to store in configstore ( #50 ) --- src/commands/login.ts | 22 +++++++++++++++------- yarn.lock | 28 +++++----------------------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/src/commands/login.ts b/src/commands/login.ts index 0a5313f..73e8622 100644 --- a/src/commands/login.ts +++ b/src/commands/login.ts @@ -6,13 +6,20 @@ const ConfigStore = require("configstore"); export default class Login extends Command { async run() { - - // console.log(await isSessionTokenActive()); const app = express(); const port = 4000; const scope = encodeURIComponent("from:cli"); const redirect = encodeURIComponent("http://localhost:4000/auth"); - const config = new ConfigStore("panacloud", { entityId: "", sessionToken: "" }); + const config = new ConfigStore("panacloud", { + user: { + id: "", + type: "", + }, + auth: { + token: "", + expiry_date: "", + }, + }); app.use(express.json()); @@ -26,9 +33,10 @@ export default class Login extends Command { const server = await app.listen(port); app.post("/auth", (req: any, res: any) => { - config.set("entityId", JSON.parse(req.body.body).entityId); - config.set("sessionToken", JSON.parse(req.body.body).sessionToken); - res.send(`Hello World!`); + const { user, sessionToken } = req.body; + config.set("user", JSON.parse(user)); + config.set("auth", JSON.parse(sessionToken)); + res.send(`Credentials Received`); server.close(); }); }; @@ -36,7 +44,7 @@ export default class Login extends Command { await ExpressServer(); await open( - `https://jovial-jennings-f5fe11.netlify.app/login?scope=${scope}&redirect_uri=${redirect}` + `https://panacloud-cli.netlify.app//login?scope=${scope}&redirect_uri=${redirect}` ); } } diff --git a/yarn.lock b/yarn.lock index 2053537..8e1413d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -239,12 +239,6 @@ "@types/connect" "*" "@types/node" "*" -"@types/chai@*": - version "4.2.19" - resolved "https://registry.npmjs.org/@types/chai/-/chai-4.2.19.tgz" - integrity sha512-jRJgpRBuY+7izT7/WNXP/LsMO9YonsstuL+xuvycDyESpoDoIAsMd7suwpB4h9oEWB+ZlPTqJJ8EHomzNhwTPQ== - -"@types/chai@^4": "@types/chai@*", "@types/chai@^4": version "4.2.21" resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.2.21.tgz#9f35a5643129df132cf3b5c1ec64046ea1af0650" @@ -1117,12 +1111,6 @@ crypto-random-string@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" integrity sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4= -debug@3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" - integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== - dependencies: - ms "2.0.0" debug@2.6.9, debug@^2.2.0, debug@^2.3.3: version "2.6.9" @@ -1276,11 +1264,6 @@ ee-first@1.1.1: resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= -"emoji-regex@>=6.0.0 <=6.1.1": - version "6.1.1" - resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-6.1.1.tgz" - integrity sha1-xs0OwbBkLio8Z6ETfvxeeW2k+I4= - emoji-regex@^7.0.1: version "7.0.3" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" @@ -3702,17 +3685,16 @@ rxjs@^6.4.0: dependencies: tslib "^1.9.0" -safe-buffer@5.1.2, safe-buffer@^5.0.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: +safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + safe-buffer@^5.0.1, safe-buffer@~5.2.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== -safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - safe-regex@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e"