|
|
@@ -200,8 +200,15 @@ module.exports = function(crowi, app) {
|
|
|
return res.redirect('/');
|
|
|
}
|
|
|
|
|
|
- debug('Catch pageShow', err);
|
|
|
- return renderPage(null, req, res);
|
|
|
+ Page.hasPortalPage(path + '/', req.user)
|
|
|
+ .then(function(page) {
|
|
|
+ if (page) {
|
|
|
+ return res.redirect(path + '/');
|
|
|
+ } else {
|
|
|
+ debug('Catch pageShow', err);
|
|
|
+ return renderPage(null, req, res);
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
};
|
|
|
|
|
|
@@ -232,14 +239,12 @@ module.exports = function(crowi, app) {
|
|
|
Page.findPage(path, req.user, null, ignoreNotFound)
|
|
|
.then(function(pageData) {
|
|
|
if (!req.form.isValid) {
|
|
|
- renderPage(pageData, req, res);
|
|
|
- return Promise.reject(new Error('form error'));
|
|
|
+ return renderPage(pageData, req, res);
|
|
|
}
|
|
|
|
|
|
if (pageData && !pageData.isUpdatable(currentRevision)) {
|
|
|
req.form.errors.push('すでに他の人がこのページを編集していたため保存できませんでした。ページを再読み込み後、自分の編集箇所のみ再度編集してください。');
|
|
|
- renderPage(pageData, req, res);
|
|
|
- return Promise.reject(new Error('form error'));
|
|
|
+ return renderPage(pageData, req, res);
|
|
|
}
|
|
|
|
|
|
if (pageData) {
|
|
|
@@ -351,6 +356,7 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
Page.findPageById(id)
|
|
|
.then(function(pageData) {
|
|
|
+
|
|
|
if (pageData.grant == Page.GRANT_RESTRICTED && !pageData.isGrantedFor(req.user)) {
|
|
|
return Page.pushToGrantedUsers(pageData, req.user);
|
|
|
}
|
|
|
@@ -383,7 +389,7 @@ module.exports = function(crowi, app) {
|
|
|
var result = {};
|
|
|
result.page = pageData;
|
|
|
|
|
|
- return res.json(ApiResponse.success(pageData));
|
|
|
+ return res.json(ApiResponse.success(result));
|
|
|
}).catch(function(err) {
|
|
|
return res.json(ApiResponse.error(err));
|
|
|
});
|