mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Added getWebsite method.
This commit is contained in:
parent
0387cf0da0
commit
d8c440453c
4 changed files with 16 additions and 6 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { validate } from 'uuid';
|
||||
import { parseSecureToken, parseToken, getItem } from 'next-basics';
|
||||
import { AUTH_TOKEN, SHARE_TOKEN_HEADER } from './constants';
|
||||
import { getWebsiteById } from 'queries';
|
||||
import { getWebsite } from 'queries';
|
||||
import { secret } from './crypto';
|
||||
|
||||
export async function getAuthToken(req) {
|
||||
|
|
@ -38,13 +39,12 @@ export async function isValidToken(token, validation) {
|
|||
export async function allowQuery(req, skipToken) {
|
||||
const { id } = req.query;
|
||||
const token = req.headers[SHARE_TOKEN_HEADER];
|
||||
const websiteId = +id;
|
||||
|
||||
const website = await getWebsiteById(websiteId);
|
||||
const website = await getWebsite(validate(id) ? { website_uuid: id } : { website_id: +id });
|
||||
|
||||
if (website) {
|
||||
if (token && token !== 'undefined' && !skipToken) {
|
||||
return isValidToken(token, { website_id: websiteId });
|
||||
return isValidToken(token, { website_id: website.website_id });
|
||||
}
|
||||
|
||||
const authToken = await getAuthToken(req);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue