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 redis auth issue

Francis Cao448d2b22410e
diff --git a/lib/middleware.ts b/lib/middleware.ts
index 013891149..5cd469c3d 100644
--- a/lib/middleware.ts
+++ b/lib/middleware.ts
@@ -36,13 +36,7 @@ export const useAuth = createMiddleware(async (req, res, next) => {
const shareToken = await parseShareToken(req);
let user = null;
- let userId = null;
-
- const { authKey } = payload || {};
-
- if (typeof payload === 'string') {
- userId = payload;
- }
+ const { userId, authKey } = payload || {};
if (validate(userId)) {
user = await getUser({ id: userId });
diff --git a/pages/api/auth/login.ts b/pages/api/auth/login.ts
index 4a0ff4cf2..0e2263466 100644
--- a/pages/api/auth/login.ts
+++ b/pages/api/auth/login.ts
@@ -47,7 +47,7 @@ export default async (
return ok(res, { token, user });
}
- const token = createSecureToken(user.id, secret());
+ const token = createSecureToken({ userId: user.id }, secret());
return ok(res, { token, user });
}