Skip to content

Commit

Permalink
🐛 fix: fix auth log (lobehub#3795)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx authored Sep 6, 2024
1 parent c9e7e31 commit 71aa405
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/libs/trpc/middleware/userAuth.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { TRPCError } from '@trpc/server';

import { enableClerk } from '@/const/auth';

import { trpc } from '../init';

export const userAuth = trpc.middleware(async (opts) => {
const { ctx } = opts;
// `ctx.user` is nullable
if (!ctx.userId) {
console.log('clerk auth:', ctx.clerkAuth);
if (enableClerk) {
console.log('clerk auth:', ctx.clerkAuth);
} else {
console.log('next auth:', ctx.nextAuth);
}
throw new TRPCError({ code: 'UNAUTHORIZED' });
}

Expand Down

0 comments on commit 71aa405

Please sign in to comment.