| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- const crypto = require('crypto');
- const randomString = () => crypto.randomBytes(6).hexSlice();
- module.exports = async keystone => {
- console.log('wtf');
- // Count existing users
- const {
- data: {
- _allUsersMeta: { count },
- },
- } = await keystone.executeQuery(
- `query {
- _allUsersMeta {
- count
- }
- }`
- );
- if (count === 0) {
- const password = randomString();
- const email = 'dev@jubilerschubert.pl';
- await keystone.executeQuery(
- `mutation initialUser($password: String, $email: String) {
- createUser(data: {name: "Admin", email: $email, isAdmin: true, password: $password}) {
- id
- }
- }`,
- {
- variables: {
- password,
- email,
- },
- }
- );
- console.log(`
- User created:
- email: ${email}
- password: ${password}
- Please change these details after initial login.
- `);
- }
- };
|