Updated redis calls.

This commit is contained in:
Mike Cao 2024-12-11 19:43:23 -08:00
parent bb5affe29a
commit 62a8b29453
9 changed files with 41 additions and 27 deletions

View file

@ -1,6 +1,6 @@
import cors from 'cors';
import debug from 'debug';
import redis from '@umami/redis-client';
import { getClient, redisEnabled } from '@umami/redis-client';
import { getAuthToken, parseShareToken } from 'lib/auth';
import { ROLES } from 'lib/constants';
import { secret } from 'lib/crypto';
@ -54,8 +54,10 @@ export const useAuth = createMiddleware(async (req, res, next) => {
if (userId) {
user = await getUser(userId);
} else if (redis.enabled && authKey) {
const key = await redis.client.get(authKey);
} else if (redisEnabled && authKey) {
const redis = getClient();
const key = await redis.get(authKey);
if (key?.userId) {
user = await getUser(key.userId);