mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
Handle website delete. Added response helper functions.
This commit is contained in:
parent
0a411a9ad6
commit
c4b75e4aec
31 changed files with 314 additions and 96 deletions
|
|
@ -1,18 +1,14 @@
|
|||
import { getWebsite, getSession, createSession } from 'lib/db';
|
||||
import { getClientInfo } from 'lib/request';
|
||||
import { uuid, isValidId, verifyToken } from 'lib/crypto';
|
||||
import { uuid, isValidId, parseToken } from 'lib/crypto';
|
||||
|
||||
export async function verifySession(req) {
|
||||
const { payload } = req.body;
|
||||
const { website: website_uuid, hostname, screen, language, session } = payload;
|
||||
|
||||
if (!isValidId(website_uuid)) {
|
||||
throw new Error(`Invalid website: ${website_uuid}`);
|
||||
}
|
||||
const token = await parseToken(session);
|
||||
|
||||
try {
|
||||
return await verifyToken(session);
|
||||
} catch {
|
||||
if (!token || !isValidId(website_uuid) || token.website_uuid !== website_uuid) {
|
||||
const { userAgent, browser, os, ip, country, device } = await getClientInfo(req, payload);
|
||||
|
||||
if (website_uuid) {
|
||||
|
|
@ -50,4 +46,6 @@ export async function verifySession(req) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue