mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
Accounts and login.
This commit is contained in:
parent
f3f0ad15f2
commit
49a55b40b4
22 changed files with 347 additions and 172 deletions
28
scripts/create-account.js
Normal file
28
scripts/create-account.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
const { PrismaClient } = require('@prisma/client');
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const exec = async () => {
|
||||
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.');
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
};
|
||||
|
||||
exec();
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import 'promise-polyfill/src/polyfill';
|
||||
import 'unfetch/polyfill';
|
||||
import { post } from 'lib/web';
|
||||
|
||||
((window, sessionKey) => {
|
||||
const {
|
||||
|
|
@ -20,19 +21,6 @@ import 'unfetch/polyfill';
|
|||
let currentUrl = `${pathname}${search}`;
|
||||
let currentRef = document.referrer;
|
||||
|
||||
/* Helper methods */
|
||||
|
||||
const post = (url, params) =>
|
||||
fetch(url, {
|
||||
method: 'post',
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(params),
|
||||
}).then(res => res.json());
|
||||
|
||||
const collect = (type, params) => {
|
||||
const payload = {
|
||||
session: store.getItem(sessionKey),
|
||||
|
|
@ -53,7 +41,7 @@ import 'unfetch/polyfill';
|
|||
return post(`${hostUrl}/api/collect`, {
|
||||
type,
|
||||
payload,
|
||||
}).then(({ ok, session }) => ok && session && store.setItem(sessionKey, session));
|
||||
}).then(({ session }) => session && store.setItem(sessionKey, session));
|
||||
};
|
||||
|
||||
const pageView = () => collect('pageview').then(() => setTimeout(loadEvents, 300));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue