mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 15:23:38 +01:00
31 lines
651 B
JavaScript
31 lines
651 B
JavaScript
const bcrypt = require('bcrypt');
|
|
const { PrismaClient } = require('@prisma/client');
|
|
const prisma = new PrismaClient();
|
|
const SALT_ROUNDS = 10;
|
|
|
|
const hashPassword = password => {
|
|
return bcrypt.hash(password, SALT_ROUNDS);
|
|
};
|
|
|
|
async function main() {
|
|
const password = await hashPassword(process.env.ADMIN_PASSWORD || 'umami');
|
|
await prisma.account.upsert({
|
|
where: { username: 'admin' },
|
|
update: {},
|
|
create: {
|
|
username: 'admin',
|
|
password: password,
|
|
is_admin: true,
|
|
},
|
|
});
|
|
}
|
|
|
|
main()
|
|
.catch(e => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|