fix redis auth issue

This commit is contained in:
Francis Cao 2023-03-03 12:30:12 -08:00
parent 3325df0d84
commit 448d2b2241
2 changed files with 2 additions and 8 deletions

View File

@ -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 });

View File

@ -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 });
}