mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 21:57:16 +01:00
Use next-basics package.
This commit is contained in:
parent
1a6af8fc41
commit
f4e0da481e
62 changed files with 255 additions and 373 deletions
|
|
@ -1,12 +1,13 @@
|
|||
import { parseSecureToken, parseToken } from './crypto';
|
||||
import { parseSecureToken, parseToken } from 'next-basics';
|
||||
import { SHARE_TOKEN_HEADER } from './constants';
|
||||
import { getWebsiteById } from 'queries';
|
||||
import { secret } from './crypto';
|
||||
|
||||
export async function getAuthToken(req) {
|
||||
try {
|
||||
const token = req.headers.authorization;
|
||||
|
||||
return parseSecureToken(token.split(' ')[1]);
|
||||
return parseSecureToken(token.split(' ')[1], secret());
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -14,7 +15,7 @@ export async function getAuthToken(req) {
|
|||
|
||||
export async function isValidToken(token, validation) {
|
||||
try {
|
||||
const result = await parseToken(token);
|
||||
const result = parseToken(token, secret());
|
||||
|
||||
if (typeof validation === 'object') {
|
||||
return !Object.keys(validation).find(key => result[key] !== validation[key]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue