umami/lib/auth.js

10 lines
277 B
JavaScript
Raw Normal View History

2020-07-28 08:52:14 +02:00
import { parse } from 'cookie';
import { verifySecureToken } from './crypto';
2020-08-05 07:45:05 +02:00
import { AUTH_COOKIE_NAME } from './constants';
2020-07-28 08:52:14 +02:00
2020-08-05 07:45:05 +02:00
export async function verifyAuthToken(req) {
const token = parse(req.headers.cookie || '')[AUTH_COOKIE_NAME];
2020-07-28 08:52:14 +02:00
return verifySecureToken(token);
2020-08-05 07:45:05 +02:00
}