File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -303,14 +303,25 @@ const KiRouter = () => {
303303 return false ;
304304 }
305305
306- const userId = user . owner ; // Assuming token contains userId
307- const userSession = await sessionRepository . getSession ( userId ) ; // Ensure session is typed
306+ const userId = user . owner ;
307+ let userSession = await sessionRepository . getSession ( userId ) ;
308+
309+ // Create new session if none exists
310+ if ( ! userSession || ! userSession . data ) {
311+ const w = new Workspace ( true , 'fs' ) ;
312+ await sessionRepository . createSession ( userId , {
313+ uploadedFiles : [ ] ,
314+ deckInfo : [ ] ,
315+ workspace : w ,
316+ } ) ;
317+ userSession = await sessionRepository . getSession ( userId ) ;
318+ }
319+
308320 if ( ! userSession || ! userSession . data ) {
309- // Check if userSession.data is defined
310321 return res . status ( 403 ) . json ( { error : 'Session expired' } ) ;
311322 }
312323
313- const files = req . files as UploadedFile [ ] ; // Ensure files are typed
324+ const files = req . files as UploadedFile [ ] ;
314325 console . log ( '[UPLOAD] Request received:' , req . body ) ;
315326 console . log ( '[UPLOAD] Starting file upload process' ) ;
316327 try {
You can’t perform that action at this time.
0 commit comments