mirror of
https://github.com/umami-software/umami.git
synced 2026-02-18 19:45:35 +01:00
feat(session): create website on session request
This commit is contained in:
parent
c881751e4f
commit
66f2075f37
6 changed files with 17137 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { getWebsiteByUuid, getSessionByUuid, createSession } from 'lib/queries';
|
||||
import { getWebsiteByUuid, getSessionByUuid, createSession, createWebsite } from 'lib/queries';
|
||||
import { getClientInfo } from 'lib/request';
|
||||
import { uuid, isValidUuid, parseToken } from 'lib/crypto';
|
||||
|
||||
|
|
@ -25,10 +25,17 @@ export async function getSession(req) {
|
|||
|
||||
const { userAgent, browser, os, ip, country, device } = await getClientInfo(req, payload);
|
||||
|
||||
const website = await getWebsiteByUuid(website_uuid);
|
||||
let website = await getWebsiteByUuid(website_uuid);
|
||||
|
||||
if (!website) {
|
||||
throw new Error(`Website not found: ${website_uuid}`);
|
||||
// throw new Error(`Website not found: ${website_uuid}`);
|
||||
const user_id = 1;
|
||||
website = await createWebsite(user_id, {
|
||||
website_uuid,
|
||||
name: website_uuid,
|
||||
domain: `http://${website_uuid}`,
|
||||
share_id: null,
|
||||
});
|
||||
}
|
||||
|
||||
const { website_id } = website;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue