Updated share token logic. Closes #1113.

This commit is contained in:
Mike Cao 2022-05-05 19:04:28 -07:00
parent b5de6b997e
commit e735a1c50d
12 changed files with 44 additions and 42 deletions

View file

@ -1,5 +1,5 @@
import { parseSecureToken, parseToken } from './crypto';
import { TOKEN_HEADER } from './constants';
import { SHARE_TOKEN_HEADER } from './constants';
import { getWebsiteById } from './queries';
export async function getAuthToken(req) {
@ -30,7 +30,7 @@ export async function isValidToken(token, validation) {
export async function allowQuery(req, skipToken) {
const { id } = req.query;
const token = req.headers[TOKEN_HEADER];
const token = req.headers[SHARE_TOKEN_HEADER];
const websiteId = +id;
const website = await getWebsiteById(websiteId);

View file

@ -5,7 +5,7 @@ export const DATE_RANGE_CONFIG = 'umami.date-range';
export const THEME_CONFIG = 'umami.theme';
export const DASHBOARD_CONFIG = 'umami.dashboard';
export const VERSION_CHECK = 'umami.version-check';
export const TOKEN_HEADER = 'x-umami-token';
export const SHARE_TOKEN_HEADER = 'x-umami-share-token';
export const HOMEPAGE_URL = 'https://umami.is';
export const VERSION_URL = 'https://github.com/mikecao/umami/releases';