소스 검색

feat: sync delete authing user before delete _User

MetaPunkGames 7 달 전
부모
커밋
2b1d787a7f
1개의 변경된 파일11개의 추가작업 그리고 2개의 파일을 삭제
  1. 11 2
      server/cloud/authing/trigger-user-save.js

+ 11 - 2
server/cloud/authing/trigger-user-save.js

@@ -55,6 +55,16 @@ export function defineUserBeforeSave(){
         // console.log(user.toJSON());
         // console.log(user?.get("password"))
         let authingUserExists = await findUserByMobileEmailUserName(user)
+        if(authingUserExists?.statusCode==200){
+            let existsUser = authingUserExists?.data;
+            let deleteRes = await managementClient.deleteUsersBatch({
+                // 替换用户 ID 数组
+                userIds: [existsUser.userId],
+                options: {
+                  userIdType: "user_id"
+                }
+            });
+        }
       });
 }
 /**
@@ -156,8 +166,7 @@ async function syncUserProfileToAuthing(user,profile){
     let authingUserExists = await findUserByMobileEmailUserName(user)
     if(authingUserExists?.statusCode==200){
         let existsUser = authingUserExists?.data;
-    userInfo.userId = existsUser.userId
-
+        userInfo.userId = existsUser.userId
     }
     delete userInfo.objectId
     userInfo.identifyStatus = userInfo.accountState