Explorar o código

Remove all relations when the deleted the user

ryuichi-e %!s(int64=6) %!d(string=hai) anos
pai
achega
5b92e850f4
Modificáronse 1 ficheiros con 2 adicións e 0 borrados
  1. 2 0
      src/server/routes/apiv3/users.js

+ 2 - 0
src/server/routes/apiv3/users.js

@@ -73,6 +73,7 @@ module.exports = (crowi) => {
     User,
     Page,
     ExternalAccount,
+    UserGroupRelation,
   } = crowi.models;
 
   const { ApiV3FormValidator } = crowi.middlewares;
@@ -455,6 +456,7 @@ module.exports = (crowi) => {
 
     try {
       const userData = await User.findById(id);
+      await UserGroupRelation.remove({ relatedUser: userData });
       await userData.statusDelete();
       await ExternalAccount.remove({ user: userData });
       await Page.removeByPath(`/user/${userData.username}`);