|
@@ -5,17 +5,13 @@ const logger = loggerFactory('growi:middleware:certify-shared-fire');
|
|
|
module.exports = (crowi) => {
|
|
module.exports = (crowi) => {
|
|
|
|
|
|
|
|
return async(req, res, next) => {
|
|
return async(req, res, next) => {
|
|
|
|
|
+ const { referer } = req.headers;
|
|
|
|
|
|
|
|
- const fileId = req.params.id || null;
|
|
|
|
|
-
|
|
|
|
|
- if (fileId == null) {
|
|
|
|
|
|
|
+ if (!referer.match(/share/)) {
|
|
|
next();
|
|
next();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // No need to check shared page if user exists
|
|
|
|
|
- if (req.user != null) {
|
|
|
|
|
- next();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const fileId = req.params.id || null;
|
|
|
|
|
|
|
|
const Attachment = crowi.model('Attachment');
|
|
const Attachment = crowi.model('Attachment');
|
|
|
const ShareLink = crowi.model('ShareLink');
|
|
const ShareLink = crowi.model('ShareLink');
|
|
@@ -34,13 +30,13 @@ module.exports = (crowi) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Is there a valid share link
|
|
// Is there a valid share link
|
|
|
- await Promise.all(shareLinks.map((sharelink) => {
|
|
|
|
|
|
|
+ shareLinks.map((sharelink) => {
|
|
|
if (!sharelink.isExpired()) {
|
|
if (!sharelink.isExpired()) {
|
|
|
logger.debug('Confirmed target file belong to a share page');
|
|
logger.debug('Confirmed target file belong to a share page');
|
|
|
req.isSharedPage = true;
|
|
req.isSharedPage = true;
|
|
|
}
|
|
}
|
|
|
return;
|
|
return;
|
|
|
- }));
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
next();
|
|
next();
|
|
|
};
|
|
};
|