Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

fix useAuth

Brian Cao648a5341e5f1
diff --git a/lib/middleware.js b/lib/middleware.js
index 8c93369a6..a79027fd2 100644
--- a/lib/middleware.js
+++ b/lib/middleware.js
@@ -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) {