@@ -136,7 +136,6 @@ app.use(i18n.init)
136
136
// static files
137
137
app . use ( '/' , express . static ( path . join ( __dirname , '/public' ) , { maxAge : config . staticCacheTime , index : false } ) )
138
138
app . 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 } ) )
140
139
app . use ( '/default.md' , express . static ( path . resolve ( __dirname , config . defaultNotePath ) , { maxAge : config . staticCacheTime } ) )
141
140
app . use ( require ( './lib/metrics' ) . router )
142
141
@@ -172,6 +171,12 @@ app.use(flash())
172
171
app . use ( passport . initialize ( ) )
173
172
app . use ( passport . session ( ) )
174
173
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
+
175
180
// check uri is valid before going further
176
181
app . use ( require ( './lib/middleware/checkURIValid' ) )
177
182
// redirect url without trailing slashes
0 commit comments