umami/cli/create-account.js

23 lines
494 B
JavaScript
Raw Normal View History

2020-07-25 02:00:56 +02:00
import { prisma } from '../lib/db';
2020-07-24 04:56:55 +02:00
2020-07-25 02:00:56 +02:00
export default async () => {
2020-07-24 04:56:55 +02:00
const account = await prisma.account.findOne({
where: {
username: 'admin',
},
});
if (!account) {
await prisma.account.create({
data: {
username: 'admin',
password: '$2a$10$BXHPV7APlV1I6WrKJt1igeJAyVsvbhMTaTAi3nHkUJFGPsYmfZq3y',
is_admin: true,
},
});
console.log('Account succesfully created.');
} else {
console.log('Account already exists.');
}
};