Skip to content

Commit

Permalink
object structure updated & added new values to store in configstore ( #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Muh-Hasan committed Aug 28, 2021
1 parent 6a92fc7 commit d15ef8e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
22 changes: 15 additions & 7 deletions src/commands/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -26,17 +33,18 @@ 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();
});
};

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}`
);
}
}
28 changes: 5 additions & 23 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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=
[email protected]:
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"

[email protected], debug@^2.2.0, debug@^2.3.3:
version "2.6.9"
Expand Down Expand Up @@ -1276,11 +1264,6 @@ [email protected]:
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"
Expand Down Expand Up @@ -3702,17 +3685,16 @@ rxjs@^6.4.0:
dependencies:
tslib "^1.9.0"

[email protected], safe-buffer@^5.0.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
[email protected], 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"
Expand Down

0 comments on commit d15ef8e

Please sign in to comment.