File tree Expand file tree Collapse file tree 3 files changed +5
-14
lines changed Expand file tree Collapse file tree 3 files changed +5
-14
lines changed Original file line number Diff line number Diff line change @@ -146,15 +146,9 @@ const startServer = async () => {
146146 try {
147147 const sessionId = decodeSessionToken ( req . cookies . session ) ;
148148 const session = await runWithAlsSession ( sessionId , ( ) =>
149- sessionId
150- ? getCache ( `validateSession:${ sessionId } ` , 60 * 5 , async ( ) =>
151- validateSessionToken ( req . cookies . session ) ,
152- )
153- : validateSessionToken ( req . cookies . session ) ,
149+ validateSessionToken ( req . cookies . session ) ,
154150 ) ;
155- if ( session . session ) {
156- req . session = session ;
157- }
151+ req . session = session ;
158152 } catch ( e ) {
159153 req . session = EMPTY_SESSION ;
160154 }
Original file line number Diff line number Diff line change @@ -75,7 +75,6 @@ export const authRouter = createTRPCRouter({
7575 deleteSessionTokenCookie ( ctx . setCookie ) ;
7676 if ( ctx . session ?. session ?. id ) {
7777 await invalidateSession ( ctx . session . session . id ) ;
78- await deleteCache ( `validateSession:${ ctx . session . session . id } ` ) ;
7978 }
8079 } ) ,
8180 signInOAuth : publicProcedure
@@ -226,9 +225,7 @@ export const authRouter = createTRPCRouter({
226225
227226 const token = generateSessionToken ( ) ;
228227 const session = await createSession ( token , user . id ) ;
229- console . log ( 'session' , session ) ;
230228 setSessionTokenCookie ( ctx . setCookie , token , session . expiresAt ) ;
231- console . log ( 'ctx.setCookie' , ctx . setCookie ) ;
232229 return {
233230 type : 'email' ,
234231 } ;
@@ -335,7 +332,6 @@ export const authRouter = createTRPCRouter({
335332 const session = await validateSessionToken ( token ) ;
336333
337334 if ( session . session ) {
338- await deleteCache ( `validateSession:${ session . session . id } ` ) ;
339335 // Re-set the cookie with updated expiration
340336 setSessionTokenCookie ( ctx . setCookie , token , session . session . expiresAt ) ;
341337 return {
Original file line number Diff line number Diff line change @@ -95,7 +95,8 @@ const enforceUserIsAuthed = t.middleware(async ({ ctx, next }) => {
9595
9696// Only used on protected routes
9797const enforceAccess = t . middleware ( async ( { ctx, next, type, getRawInput } ) => {
98- return runWithAlsSession ( ctx . session . session ?. id , async ( ) => {
98+ const sessionId = ctx . session ?. session ?. id ?? null ;
99+ return runWithAlsSession ( sessionId , async ( ) => {
99100 const rawInput = await getRawInput ( ) ;
100101 if ( type === 'mutation' && process . env . DEMO_USER_ID ) {
101102 throw new TRPCError ( {
@@ -153,7 +154,7 @@ const loggerMiddleware = t.middleware(
153154) ;
154155
155156const sessionScopeMiddleware = t . middleware ( async ( { ctx, next } ) => {
156- const sessionId = ctx . session . session ?. id ?? null ;
157+ const sessionId = ctx . session ? .session ?. id ?? null ;
157158 return runWithAlsSession ( sessionId , async ( ) => {
158159 return next ( ) ;
159160 } ) ;
You can’t perform that action at this time.
0 commit comments