@@ -136,7 +136,6 @@ app.use(i18n.init)
136136// static files
137137app . use ( '/' , express . static ( path . join ( __dirname , '/public' ) , { maxAge : config . staticCacheTime , index : false } ) )
138138app . use ( '/docs' , express . static ( path . resolve ( __dirname , config . docsPath ) , { maxAge : config . staticCacheTime } ) )
139- app . use ( '/uploads' , express . static ( path . resolve ( __dirname , config . uploadsPath ) , { maxAge : config . staticCacheTime } ) )
140139app . use ( '/default.md' , express . static ( path . resolve ( __dirname , config . defaultNotePath ) , { maxAge : config . staticCacheTime } ) )
141140app . use ( require ( './lib/metrics' ) . router )
142141
@@ -172,6 +171,12 @@ app.use(flash())
172171app . use ( passport . initialize ( ) )
173172app . use ( passport . session ( ) )
174173
174+ // routes with sessions
175+ app . use ( '/uploads' , ( req , res , next ) => {
176+ if ( req . isAuthenticated ( ) ) next ( )
177+ else response . errorNotFound ( req , res )
178+ } , express . static ( path . resolve ( __dirname , config . uploadsPath ) , { maxAge : config . staticCacheTime } ) )
179+
175180// check uri is valid before going further
176181app . use ( require ( './lib/middleware/checkURIValid' ) )
177182// redirect url without trailing slashes
0 commit comments