ryoji-s 3 лет назад
Родитель
Сommit
055efe2f30

+ 4 - 2
packages/app/src/server/models/page.ts

@@ -955,9 +955,11 @@ schema.statics.findNonEmptyClosestAncestor = async function(path: string): Promi
   return ancestors[0];
 };
 
-schema.statics.removeByPath = async function(
-    userHomePagePath: string,
+schema.statics.removeUserHome = async function(
+    username: string,
 ): Promise<{ deleteManyResult: DeleteResult, findOneAndRemoveResult: PageDocument & HasObjectId | null }> {
+  const userHomePagePath = `/user/${username}`;
+
   // https://regex101.com/r/PY1tI5/1
   const regex = new RegExp(`^${userHomePagePath}/.+`);
 

+ 2 - 2
packages/app/src/server/routes/apiv3/users.js

@@ -676,11 +676,11 @@ module.exports = (crowi) => {
 
     try {
       const userData = await User.findById(id);
-      const userHomePagePath = `/user/${userData.username}`;
+      const username = userData.username;
       await UserGroupRelation.remove({ relatedUser: userData });
       await userData.statusDelete();
       await ExternalAccount.remove({ user: userData });
-      if (isUserPageDeletionEnabled) await Page.removeByPath(userHomePagePath);
+      if (isUserPageDeletionEnabled) await Page.removeUserHome(username);
 
       const serializedUserData = serializeUserSecurely(userData);