fix useAuth

This commit is contained in:
Brian Cao 2022-11-08 12:51:04 -08:00
parent 208fcb8418
commit 648a5341e5

View File

@ -2,7 +2,8 @@ import { createMiddleware, unauthorized, badRequest } from 'next-basics';
import debug from 'debug';
import cors from 'cors';
import { findSession } from 'lib/session';
import { parseAuthToken, parseShareToken } from 'lib/auth';
import { parseAuthToken, parseShareToken, getAuthToken } from 'lib/auth';
import redis from 'lib/redis';
const log = debug('umami:middleware');
@ -21,7 +22,7 @@ export const useSession = createMiddleware(async (req, res, next) => {
});
export const useAuth = createMiddleware(async (req, res, next) => {
const token = await parseAuthToken(req);
const token = redis.enabled ? await redis.get(getAuthToken(req)) : await parseAuthToken(req);
const shareToken = await parseShareToken(req);
if (!token && !shareToken) {