|
|
@@ -1106,9 +1106,10 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
Page.findPageByPath(newPagePath)
|
|
|
.then(function(page) {
|
|
|
- // if page found, cannot cannot rename to that path
|
|
|
- return res.json(ApiResponse.error(`このページ名は作成できません (${newPagePath})。ページが存在します。`));
|
|
|
- }).catch(function(err) {
|
|
|
+ if (page != null) {
|
|
|
+ // if page found, cannot cannot rename to that path
|
|
|
+ return res.json(ApiResponse.error(`このページ名は作成できません (${newPagePath})。ページが存在します。`));
|
|
|
+ }
|
|
|
|
|
|
Page.findPageById(pageId)
|
|
|
.then(function(pageData) {
|
|
|
@@ -1124,12 +1125,14 @@ module.exports = function(crowi, app) {
|
|
|
return Page.rename(pageData, newPagePath, req.user, options);
|
|
|
}
|
|
|
|
|
|
- }).then(function() {
|
|
|
+ })
|
|
|
+ .then(function() {
|
|
|
var result = {};
|
|
|
result.page = page;
|
|
|
|
|
|
return res.json(ApiResponse.success(result));
|
|
|
- }).catch(function(err) {
|
|
|
+ })
|
|
|
+ .catch(function(err) {
|
|
|
return res.json(ApiResponse.error('Failed to update page.'));
|
|
|
});
|
|
|
});
|