fix useAuth
This commit is contained in:
@@ -2,7 +2,8 @@ import { createMiddleware, unauthorized, badRequest } from 'next-basics';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import { findSession } from 'lib/session';
|
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');
|
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) => {
|
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);
|
const shareToken = await parseShareToken(req);
|
||||||
|
|
||||||
if (!token && !shareToken) {
|
if (!token && !shareToken) {
|
||||||
|
|||||||
Reference in New Issue
Block a user