mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-25 02:36:20 +01:00
fix useAuth
This commit is contained in:
parent
208fcb8418
commit
648a5341e5
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user