Skip to content

Commit d74e201

Browse files
committed
add auth in /uplods
1 parent cb9af06 commit d74e201

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: app.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,11 @@ app.locals.enableDropBoxSave = config.isDropboxEnable
226226
app.locals.enableGitHubGist = config.isGitHubEnable
227227
app.locals.enableGitlabSnippets = config.isGitlabSnippetsEnable
228228

229-
logger.info('add auth into /uploads')
229+
app.use('/uploads', (req, res, next) => {
230+
if (req.session.user) next()
231+
else response.errorNotFound(req, res)
232+
}, express.static(path.resolve(__dirname, config.uploadsPath), { maxAge: config.staticCacheTime }))
230233

231-
app.use('/uploads', express.static(path.resolve(__dirname, config.uploadsPath), { maxAge: config.staticCacheTime }))
232234
app.use(require('./lib/routes').router)
233235

234236
// response not found if no any route matxches

0 commit comments

Comments
 (0)