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.

Updated middleware check.

Mike Cao091716e037e3
diff --git a/lib/middleware.js b/lib/middleware.js
index 5660388e5..09d790d1c 100644
--- a/lib/middleware.js
+++ b/lib/middleware.js
@@ -26,11 +26,11 @@ export const useSession = createMiddleware(async (req, res, next) => {
export const useAuth = createMiddleware(async (req, res, next) => {
const token = getAuthToken(req);
- const payload = parseSecureToken(token, secret()) || {};
+ const payload = parseSecureToken(token, secret());
const shareToken = await parseShareToken(req);
let user;
- const { userId, key } = payload;
+ const { userId, key } = payload || {};
if (validate(userId)) {
user = await getUser({ id: userId });