|
|
@@ -4,6 +4,7 @@ import {
|
|
|
pathUtils,
|
|
|
templateChecker,
|
|
|
} from '@growi/core/dist/utils';
|
|
|
+import { isUserPage } from '@growi/core/dist/utils/page-path-utils';
|
|
|
import { removeHeadingSlash } from '@growi/core/dist/utils/path-utils';
|
|
|
import { differenceInYears } from 'date-fns/differenceInYears';
|
|
|
import escapeStringRegexp from 'escape-string-regexp';
|
|
|
@@ -340,7 +341,7 @@ export const getPageSchema = (crowi) => {
|
|
|
* @param {User} user
|
|
|
*/
|
|
|
pageSchema.statics.isAccessiblePageByViewer = async function (id, user) {
|
|
|
- const baseQuery = this.count({ _id: id });
|
|
|
+ const baseQuery = this.findOne({ _id: id }).select('path');
|
|
|
|
|
|
const userGroups =
|
|
|
user != null
|
|
|
@@ -355,8 +356,21 @@ export const getPageSchema = (crowi) => {
|
|
|
const queryBuilder = new this.PageQueryBuilder(baseQuery);
|
|
|
queryBuilder.addConditionToFilteringByViewer(user, userGroups, true);
|
|
|
|
|
|
- const count = await queryBuilder.query.exec();
|
|
|
- return count > 0;
|
|
|
+ const page = await queryBuilder.query.exec();
|
|
|
+
|
|
|
+ if (!page) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ const disabledUserPages = configManager.getConfig(
|
|
|
+ 'security:disableUserPages',
|
|
|
+ );
|
|
|
+
|
|
|
+ if (disabledUserPages && isUserPage(page.path)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
};
|
|
|
|
|
|
// find page by path
|