Przeglądaj źródła

Merge pull request #21031 from overleaf/msm-clean-collabratec-tokens

[web] cleanup collabratec tokens

GitOrigin-RevId: 0ad73ca5d4c4c82d79e2ec7119c5b77a83b7086f
Miguel Serrano 1 rok temu
rodzic
commit
d6f8645e8c

+ 4 - 0
services/web/app/src/Features/User/UserDeleter.js

@@ -158,4 +158,8 @@ async function _cleanupUser(user) {
   await InstitutionsAPI.promises.deleteAffiliations(user._id)
   await InstitutionsAPI.promises.deleteAffiliations(user._id)
   await SubscriptionUpdater.promises.removeUserFromAllGroups(user._id)
   await SubscriptionUpdater.promises.removeUserFromAllGroups(user._id)
   await UserMembershipsHandler.promises.removeUserFromAllEntities(user._id)
   await UserMembershipsHandler.promises.removeUserFromAllEntities(user._id)
+  await Modules.promises.hooks.fire('cleanupPersonalAccessTokens', user._id, [
+    'collabratec',
+    'git_bridge',
+  ])
 }
 }

+ 11 - 0
services/web/test/unit/src/User/UserDeleterTests.js

@@ -236,6 +236,17 @@ describe('UserDeleter', function () {
             ).to.have.been.calledWith(this.userId)
             ).to.have.been.calledWith(this.userId)
           })
           })
 
 
+          it('should cleanup collabratec access tokens', async function () {
+            await this.UserDeleter.promises.deleteUser(this.userId, {
+              ipAddress: this.ipAddress,
+            })
+            expect(this.Modules.promises.hooks.fire).to.have.been.calledWith(
+              'cleanupPersonalAccessTokens',
+              this.userId,
+              ['collabratec', 'git_bridge']
+            )
+          })
+
           it('should fire the deleteUser hook for modules', async function () {
           it('should fire the deleteUser hook for modules', async function () {
             await this.UserDeleter.promises.deleteUser(this.userId, {
             await this.UserDeleter.promises.deleteUser(this.userId, {
               ipAddress: this.ipAddress,
               ipAddress: this.ipAddress,