diff --git a/dataset.js b/dataset.js index e2d5b12..693e8cf 100755 --- a/dataset.js +++ b/dataset.js @@ -2,6 +2,7 @@ require('dotenv').config(); const fs = require('fs'); const path = require('path'); +const bcrypt = require('bcryptjs'); const { GraphQLProcessor, JobProcessor @@ -71,6 +72,12 @@ function commandListDatasets(cmd) { }); } +function commandHashPassword(pw) { + const salt = bcrypt.genSaltSync(10); + const hash = bcrypt.hashSync(pw, salt); + console.log("Hash Password:", pw, "->", hash); +} + async function importData() { program .command('import') @@ -105,6 +112,12 @@ async function importData() { .command('list') .description('list all available datasets') .action(commandListDatasets); + + program + .command('hash') + .description('hash a password') + .argument('', 'the password to be hashed') + .action(commandHashPassword); await program.parseAsync(process.argv); } diff --git a/datasets/demo-shop/README.md b/datasets/demo-shop/README.md index 03ef92c..f707bfc 100644 --- a/datasets/demo-shop/README.md +++ b/datasets/demo-shop/README.md @@ -87,4 +87,56 @@ npm run import:demoshop:objects -- --apiKey= -- --NODE_ENV=local npm run import:demoshop:objects -- --apiKey= -- --NODE_ENV=production # or: npm run import:demoshop:objects -- --apiKey= # default is development +``` + +## Login + +For login as any existing user of this dataset, the credentials are as follows: + +**Root Admin** (all permission in domain) +``` +User: root.admin@restorecommerce.io +Password: restorecommerce.io +``` + +**Shop Admin 000** (all permission in shop) +``` +User: shop000.admin000@restorecommerce.io +Password: restorecommerce.io +``` + +**Sales 000** (permission to maintain shop) +``` +User: shop000.sales000@restorecommerce.io +Password: restorecommerce.io +``` + +**Moderator 000** (permission to maintain customer organization 000) +``` +User: customer000.moderator000@restorecommerce.io +Password: restorecommerce.io +``` + +**Moderator 001** (permission to maintain customer organization 001) +``` +User: customer001.moderator000@restorecommerce.io +Password: restorecommerce.io +``` + +**Member 000** (permission to make orders for organization 000) +``` +User: customer000.member000@restorecommerce.io +Password: restorecommerce.io +``` + +**Member 001** (permission to make orders for organization 001) +``` +User: customer001.member000@restorecommerce.io +Password: restorecommerce.io +``` + +**User 000** (permission to make orders as individual) +``` +User: customer002.user000@restorecommerce.io +Password: restorecommerce.io ``` \ No newline at end of file diff --git a/datasets/demo-shop/data/seed-data/users.yaml b/datasets/demo-shop/data/seed-data/users.yaml index 41958a7..4dfcfb4 100644 --- a/datasets/demo-shop/data/seed-data/users.yaml +++ b/datasets/demo-shop/data/seed-data/users.yaml @@ -65,7 +65,6 @@ firstName: Root lastName: Admin email: root.admin@restorecommerce.io - password: CNQJrH%KAayeDpf3h defaultScope: restorecommerce-demo-root-organization roleAssociations: - id: restorecommerce-demo-root-organization-administrator-r-id @@ -97,7 +96,7 @@ newEmail: "" active: true activationCode: "" - passwordHash: "" + passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua guest: false image: id: "" @@ -122,7 +121,6 @@ firstName: Shop000 lastName: Admin000 email: shop000.admin000@restorecommerce.io - password: CNQJrH%KAayeDpf3h defaultScope: restorecommerce-demo-shop-000-organization roleAssociations: - id: restorecommerce-demo-shop-000-organization-administrator-r-id @@ -154,7 +152,7 @@ newEmail: "" active: true activationCode: "" - passwordHash: "" + passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua guest: false image: id: "" @@ -179,7 +177,6 @@ firstName: Shop000 lastName: Sales000 email: shop000.sales000@restorecommerce.io - password: CNQJrH%KAayeDpf3h defaultScope: restorecommerce-demo-shop-000-organization roleAssociations: - id: restorecommerce-demo-shop-000-organization-sales-r-id @@ -211,7 +208,7 @@ newEmail: "" active: true activationCode: "" - passwordHash: "" + passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua guest: false image: id: "" @@ -236,7 +233,6 @@ firstName: Customer000 lastName: Moderator000 email: customer000.moderator000@restorecommerce.io - password: CNQJrH%KAayeDpf3h defaultScope: restorecommerce-demo-customer-000-organization roleAssociations: - id: restorecommerce-demo-customer-000-organization-moderator-r-id @@ -284,7 +280,7 @@ newEmail: "" active: true activationCode: "" - passwordHash: "" + passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua guest: false image: id: "" @@ -309,7 +305,6 @@ firstName: Customer001 lastName: Moderator000 email: customer001.moderator000@restorecommerce.io - password: CNQJrH%KAayeDpf3h defaultScope: restorecommerce-demo-customer-001-organization roleAssociations: - id: restorecommerce-demo-customer-001-organization-moderator-r-id @@ -357,7 +352,7 @@ newEmail: "" active: true activationCode: "" - passwordHash: "" + passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua guest: false image: id: "" @@ -382,7 +377,6 @@ firstName: Customer000 lastName: Member000 email: customer000.member000@restorecommerce.io - password: CNQJrH%KAayeDpf3h defaultScope: restorecommerce-demo-customer-000-organization roleAssociations: - id: restorecommerce-demo-customer-000-organization-member-r-id @@ -430,7 +424,7 @@ newEmail: "" active: true activationCode: "" - passwordHash: "" + passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua guest: false image: id: "" @@ -455,7 +449,6 @@ firstName: Customer001 lastName: Member000 email: customer001.member000@restorecommerce.io - password: CNQJrH%KAayeDpf3h defaultScope: restorecommerce-demo-customer-001-organization roleAssociations: - id: restorecommerce-demo-customer-001-organization-member-r-id @@ -503,7 +496,7 @@ newEmail: "" active: true activationCode: "" - passwordHash: "" + passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua guest: false image: id: "" @@ -528,7 +521,6 @@ firstName: Customer002 lastName: User000 email: customer002.user000@restorecommerce.io - password: CNQJrH%KAayeDpf3h defaultScope: restorecommerce-demo-customers-organization roleAssociations: - id: restorecommerce-demo-shops-organization-customer-r-id @@ -568,7 +560,7 @@ newEmail: "" active: true activationCode: "" - passwordHash: "" + passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua guest: false image: id: "" diff --git a/datasets/system/README.md b/datasets/system/README.md index 41c6aa3..2a951d4 100644 --- a/datasets/system/README.md +++ b/datasets/system/README.md @@ -18,7 +18,7 @@ All data is imported via the GraphQL API exposed by the [facade-srv](https://git All possible operations are exposed through JS scripts. These scripts either execute GraphQL mutations/ queries through the `dataset.js` script. -The `import.js` also includes command-line options such as specifying if we wish +The `dataset.js` also includes command-line options such as specifying if we wish to import the data locally or into the production environment. ### Current supported jobs are @@ -68,3 +68,13 @@ npm run env:token By default, the GraphQL importer uses the configuration file `config.json` to read data regarding endpoints for retrieving the API key and executing mutations/ queries. + +## Login + +For login as any existing user of this dataset, the credentials are as follows: + +**Tech User** (Superadmin) +``` +User: tech-user@restorecommerce.io +Password: restorecommerce.io +``` diff --git a/datasets/system/data/seed-data/users.yaml b/datasets/system/data/seed-data/users.yaml index a490961..49c89e0 100644 --- a/datasets/system/data/seed-data/users.yaml +++ b/datasets/system/data/seed-data/users.yaml @@ -4,7 +4,6 @@ firstName: Tech lastName: User email: tech-user@restorecommerce.io - password: CNQJrH%KAayeDpf3h defaultScope: "" roleAssociations: - id: superadministrator-r-role-assoc-id @@ -28,7 +27,7 @@ newEmail: "" active: true activationCode: "" - passwordHash: "" + passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua guest: false image: id: "" diff --git a/package-lock.json b/package-lock.json index b19dca3..3f214fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ ], "dependencies": { "@restorecommerce/gql-bot": "^1.0.1", + "bcryptjs": "^2.4.3", "commander": "^9.4.1", "dotenv": "^16.0.3" }, @@ -3534,6 +3535,11 @@ } ] }, + "node_modules/bcryptjs": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", + "integrity": "sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ==" + }, "node_modules/before-after-hook": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", diff --git a/package.json b/package.json index 799a8a7..14dcfaf 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ ], "dependencies": { "@restorecommerce/gql-bot": "^1.0.1", + "bcryptjs": "^2.4.3", "commander": "^9.4.1", "dotenv": "^16.0.3" },