Skip to content

Commit

Permalink
fix(users): add known passwords to each user
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerald Baulig committed Mar 20, 2024
1 parent 6e0b5b8 commit a297e5c
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 19 deletions.
13 changes: 13 additions & 0 deletions dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require('dotenv').config();
const fs = require('fs');
const path = require('path');
const bcrypt = require('bcryptjs');
const {
GraphQLProcessor,
JobProcessor
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -105,6 +112,12 @@ async function importData() {
.command('list')
.description('list all available datasets')
.action(commandListDatasets);

program
.command('hash')
.description('hash a password')
.argument('<pw>', 'the password to be hashed')
.action(commandHashPassword);

await program.parseAsync(process.argv);
}
Expand Down
52 changes: 52 additions & 0 deletions datasets/demo-shop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,56 @@ npm run import:demoshop:objects -- --apiKey=<access_token> -- --NODE_ENV=local
npm run import:demoshop:objects -- --apiKey=<access_token> -- --NODE_ENV=production
# or:
npm run import:demoshop:objects -- --apiKey=<access_token> # 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: [email protected]
Password: restorecommerce.io
```

**Shop Admin 000** (all permission in shop)
```
User: [email protected]
Password: restorecommerce.io
```

**Sales 000** (permission to maintain shop)
```
User: [email protected]
Password: restorecommerce.io
```

**Moderator 000** (permission to maintain customer organization 000)
```
User: [email protected]
Password: restorecommerce.io
```

**Moderator 001** (permission to maintain customer organization 001)
```
User: [email protected]
Password: restorecommerce.io
```

**Member 000** (permission to make orders for organization 000)
```
User: [email protected]
Password: restorecommerce.io
```

**Member 001** (permission to make orders for organization 001)
```
User: [email protected]
Password: restorecommerce.io
```

**User 000** (permission to make orders as individual)
```
User: [email protected]
Password: restorecommerce.io
```
24 changes: 8 additions & 16 deletions datasets/demo-shop/data/seed-data/users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
firstName: Root
lastName: Admin
email: [email protected]
password: CNQJrH%KAayeDpf3h
defaultScope: restorecommerce-demo-root-organization
roleAssociations:
- id: restorecommerce-demo-root-organization-administrator-r-id
Expand Down Expand Up @@ -97,7 +96,7 @@
newEmail: ""
active: true
activationCode: ""
passwordHash: ""
passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua
guest: false
image:
id: ""
Expand All @@ -122,7 +121,6 @@
firstName: Shop000
lastName: Admin000
email: [email protected]
password: CNQJrH%KAayeDpf3h
defaultScope: restorecommerce-demo-shop-000-organization
roleAssociations:
- id: restorecommerce-demo-shop-000-organization-administrator-r-id
Expand Down Expand Up @@ -154,7 +152,7 @@
newEmail: ""
active: true
activationCode: ""
passwordHash: ""
passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua
guest: false
image:
id: ""
Expand All @@ -179,7 +177,6 @@
firstName: Shop000
lastName: Sales000
email: [email protected]
password: CNQJrH%KAayeDpf3h
defaultScope: restorecommerce-demo-shop-000-organization
roleAssociations:
- id: restorecommerce-demo-shop-000-organization-sales-r-id
Expand Down Expand Up @@ -211,7 +208,7 @@
newEmail: ""
active: true
activationCode: ""
passwordHash: ""
passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua
guest: false
image:
id: ""
Expand All @@ -236,7 +233,6 @@
firstName: Customer000
lastName: Moderator000
email: [email protected]
password: CNQJrH%KAayeDpf3h
defaultScope: restorecommerce-demo-customer-000-organization
roleAssociations:
- id: restorecommerce-demo-customer-000-organization-moderator-r-id
Expand Down Expand Up @@ -284,7 +280,7 @@
newEmail: ""
active: true
activationCode: ""
passwordHash: ""
passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua
guest: false
image:
id: ""
Expand All @@ -309,7 +305,6 @@
firstName: Customer001
lastName: Moderator000
email: [email protected]
password: CNQJrH%KAayeDpf3h
defaultScope: restorecommerce-demo-customer-001-organization
roleAssociations:
- id: restorecommerce-demo-customer-001-organization-moderator-r-id
Expand Down Expand Up @@ -357,7 +352,7 @@
newEmail: ""
active: true
activationCode: ""
passwordHash: ""
passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua
guest: false
image:
id: ""
Expand All @@ -382,7 +377,6 @@
firstName: Customer000
lastName: Member000
email: [email protected]
password: CNQJrH%KAayeDpf3h
defaultScope: restorecommerce-demo-customer-000-organization
roleAssociations:
- id: restorecommerce-demo-customer-000-organization-member-r-id
Expand Down Expand Up @@ -430,7 +424,7 @@
newEmail: ""
active: true
activationCode: ""
passwordHash: ""
passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua
guest: false
image:
id: ""
Expand All @@ -455,7 +449,6 @@
firstName: Customer001
lastName: Member000
email: [email protected]
password: CNQJrH%KAayeDpf3h
defaultScope: restorecommerce-demo-customer-001-organization
roleAssociations:
- id: restorecommerce-demo-customer-001-organization-member-r-id
Expand Down Expand Up @@ -503,7 +496,7 @@
newEmail: ""
active: true
activationCode: ""
passwordHash: ""
passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua
guest: false
image:
id: ""
Expand All @@ -528,7 +521,6 @@
firstName: Customer002
lastName: User000
email: [email protected]
password: CNQJrH%KAayeDpf3h
defaultScope: restorecommerce-demo-customers-organization
roleAssociations:
- id: restorecommerce-demo-shops-organization-customer-r-id
Expand Down Expand Up @@ -568,7 +560,7 @@
newEmail: ""
active: true
activationCode: ""
passwordHash: ""
passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua
guest: false
image:
id: ""
Expand Down
12 changes: 11 additions & 1 deletion datasets/system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: [email protected]
Password: restorecommerce.io
```
3 changes: 1 addition & 2 deletions datasets/system/data/seed-data/users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
firstName: Tech
lastName: User
email: [email protected]
password: CNQJrH%KAayeDpf3h
defaultScope: ""
roleAssociations:
- id: superadministrator-r-role-assoc-id
Expand All @@ -28,7 +27,7 @@
newEmail: ""
active: true
activationCode: ""
passwordHash: ""
passwordHash: $2a$10$mo3euNumYtu3kVe8HFV/bepdRhhDDUG4wPmstSF3XbHPMHJ9TOgua
guest: false
image:
id: ""
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
],
"dependencies": {
"@restorecommerce/gql-bot": "^1.0.1",
"bcryptjs": "^2.4.3",
"commander": "^9.4.1",
"dotenv": "^16.0.3"
},
Expand Down

0 comments on commit a297e5c

Please sign in to comment.