Merge branch 'dev' into feat/um-23-v2-schema-init

This commit is contained in:
Brian Cao 2022-10-31 23:48:12 -07:00
commit 689b732829
11 changed files with 1107 additions and 892 deletions

View file

@ -1,22 +1,26 @@
import { parseSecureToken, parseToken } from 'next-basics';
import { getUser, getWebsite } from 'queries';
import debug from 'debug';
import { SHARE_TOKEN_HEADER, TYPE_ACCOUNT, TYPE_WEBSITE } from 'lib/constants';
import { secret } from 'lib/crypto';
export function getAuthToken(req) {
const log = debug('umami:auth');
export function parseAuthToken(req) {
try {
const token = req.headers.authorization;
return parseSecureToken(token.split(' ')[1], secret());
} catch {
} catch (e) {
log(e);
return null;
}
}
export function getShareToken(req) {
export function parseShareToken(req) {
try {
return parseToken(req.headers[SHARE_TOKEN_HEADER], secret());
} catch {
} catch (e) {
log(e);
return null;
}
}
@ -29,6 +33,7 @@ export function isValidToken(token, validation) {
return validation(token);
}
} catch (e) {
log(e);
return false;
}