Create first admin account

You must have a least one admin account before being able to login on the admin interface (then being able to create other user). Create the first user with mongo request.

mongosh
use hcw-athome;
db.user.insertOne({email:"admin@example.com", firstName:"Admin", lastName:"", role: "admin", createdAt: new Date().getTime(), password: "$2b$10$uip0TKwn.kbO1s1C3jO0au4ymxjkgd.kg9ueH2oV02I4gJBKzH.2m", "updatedAt": new Date().getTime(), "username" : "admin@example.com", phoneNumber: ""})

This command will create user with login "admin@example.com" and password "admin".

If you need to customize this passsword and you have nodejs installed (or you do on your server), you can use the following script, by example into password.js, don't forgot to update 'not hashed password'.

const bcrypt = require('bcrypt');

bcrypt.hash('not hashed password', 10, function(err, hash) {
if(err) console.log(err)
console.log(hash);
});

You will need to install bcrypt with the following command.

npm install bcrypt

Then run the script with:

node password.js
Rating
0 0

There are no comments for now.

to be the first to leave a comment.