Przeglądaj źródła

update users remove endpoint for remove by path

ryoji-s 3 lat temu
rodzic
commit
dbde845742
1 zmienionych plików z 3 dodań i 1 usunięć
  1. 3 1
      packages/app/src/server/routes/apiv3/users.js

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

@@ -672,13 +672,15 @@ module.exports = (crowi) => {
    */
   router.delete('/:id/remove', loginRequiredStrictly, adminRequired, certifyUserOperationOtherThenYourOwn, addActivity, async(req, res) => {
     const { id } = req.params;
+    const isUserPageDeletionEnabled = crowi.configManager.getConfig('crowi', 'security:isUserPageDeletionEnabled');
 
     try {
       const userData = await User.findById(id);
+      const userHomePagePath = `/user/${userData.username}`;
       await UserGroupRelation.remove({ relatedUser: userData });
       await userData.statusDelete();
       await ExternalAccount.remove({ user: userData });
-      await Page.removeByPath(`/user/${userData.username}`);
+      if (isUserPageDeletionEnabled) await Page.removeByPath(userHomePagePath);
 
       const serializedUserData = serializeUserSecurely(userData);