feat: implement user session management with Redis and add game token verification
This commit is contained in:
1 parent
29523ef22f
commit
f01a21f2f0
28 files changed
+477
-27
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { initTRPC } from '@trpc/server';
|
||||
import { initTRPC, TRPCError } from '@trpc/server';
|
||||
|
||||
import type { GameApiContext } from './context.js';
|
||||
|
||||
@@ -6,3 +6,17 @@ const t = initTRPC.context<GameApiContext>().create();
|
||||
|
||||
export const router = t.router;
|
||||
export const procedure = t.procedure;
|
||||
export const authedProcedure = t.procedure.use(({ ctx, next }) => {
|
||||
if (!ctx.auth) {
|
||||
throw new TRPCError({
|
||||
code: 'UNAUTHORIZED',
|
||||
message: 'Unauthorized',
|
||||
});
|
||||
}
|
||||
return next({
|
||||
ctx: {
|
||||
...ctx,
|
||||
auth: ctx.auth,
|
||||
},
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user