mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
Implement session caching.
This commit is contained in:
parent
0b131392fc
commit
3d1dc08491
4 changed files with 31 additions and 11 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { getWebsiteByUuid, getSessionByUuid, createSession } from 'lib/queries';
|
||||
import { getClientInfo } from 'lib/request';
|
||||
import { uuid, isValidUuid } from 'lib/crypto';
|
||||
import { uuid, isValidUuid, parseToken } from 'lib/crypto';
|
||||
|
||||
export async function getSession(req) {
|
||||
const { payload } = req.body;
|
||||
|
|
@ -9,7 +9,15 @@ export async function getSession(req) {
|
|||
throw new Error('Invalid request');
|
||||
}
|
||||
|
||||
const { website: website_uuid, hostname, screen, language } = payload;
|
||||
const { website: website_uuid, hostname, screen, language, cache } = payload;
|
||||
|
||||
if (cache) {
|
||||
const result = await parseToken(cache);
|
||||
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValidUuid(website_uuid)) {
|
||||
throw new Error(`Invalid website: ${website_uuid}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue