Răsfoiți Sursa

[web] Remove the unused endpoint `/user/emails/resend_confirmation` (#27416)

* Remove the unused endpoint `/user/emails/resend_confirmation`

* Remove exported middleware `resendConfirmationEmail`

* Revert "Remove exported middleware `resendConfirmationEmail`"

This reverts commit 7989bf25465dbc9b68c9d1af0d64d1097a747b55.

GitOrigin-RevId: 8054c6f217a734881093f78599a7b2be29436793
Antoine Clausse 1 an în urmă
părinte
comite
535a9774ef

+ 0 - 21
services/web/app/src/Features/User/UserEmailsController.js

@@ -54,25 +54,6 @@ async function _sendSecurityAlertEmail(user, email) {
   await EmailHandler.promises.sendEmail('securityAlert', emailOptions)
 }
 
-async function resendConfirmation(req, res) {
-  const userId = SessionManager.getLoggedInUserId(req.session)
-  const email = EmailHelper.parseEmail(req.body.email)
-  if (!email) {
-    return res.sendStatus(422)
-  }
-  const user = await UserGetter.promises.getUserByAnyEmail(email, { _id: 1 })
-
-  if (!user || user._id.toString() !== userId) {
-    return res.sendStatus(422)
-  }
-
-  await UserEmailsConfirmationHandler.promises.sendConfirmationEmail(
-    userId,
-    email
-  )
-  res.sendStatus(200)
-}
-
 async function sendReconfirmation(req, res) {
   const userId = SessionManager.getLoggedInUserId(req.session)
   const email = EmailHelper.parseEmail(req.body.email)
@@ -659,8 +640,6 @@ const UserEmailsController = {
     )
   },
 
-  resendConfirmation: expressify(resendConfirmation),
-
   sendReconfirmation: expressify(sendReconfirmation),
 
   sendExistingEmailConfirmationCode: expressify(

+ 0 - 8
services/web/app/src/router.mjs

@@ -363,14 +363,6 @@ async function initialize(webRouter, privateApiRouter, publicApiRouter) {
     UserEmailsController.checkExistingEmailConfirmationCode
   )
 
-  webRouter.post(
-    '/user/emails/resend_confirmation',
-    AuthenticationController.requireLogin(),
-    RateLimiterMiddleware.rateLimit(rateLimiters.resendConfirmation),
-    await Modules.middleware('resendConfirmationEmail'),
-    UserEmailsController.resendConfirmation
-  )
-
   webRouter.get(
     '/user/emails/primary-email-check',
     AuthenticationController.requireLogin(),

+ 0 - 3
services/web/frontend/stories/project-list/helpers/emails.ts

@@ -100,9 +100,6 @@ export function setReconfirmationMeta() {
 
 export function reconfirmationSetupMocks(fetchMock: FetchMock) {
   defaultSetupMocks(fetchMock)
-  fetchMock.post(/\/user\/emails\/resend_confirmation/, 200, {
-    delay: MOCK_DELAY,
-  })
 }
 
 export function setReconfirmAffiliationMeta() {

+ 0 - 73
services/web/test/unit/src/User/UserEmailsControllerTests.js

@@ -607,79 +607,6 @@ describe('UserEmailsController', function () {
     })
   })
 
-  describe('resendConfirmation', function () {
-    beforeEach(function () {
-      this.EmailHelper.parseEmail.returnsArg(0)
-      this.UserGetter.promises.getUserByAnyEmail.resolves({
-        _id: this.user._id,
-      })
-      this.req = {
-        body: {},
-      }
-      this.res = {
-        sendStatus: sinon.stub(),
-      }
-      this.next = sinon.stub()
-      this.UserEmailsConfirmationHandler.sendConfirmationEmail = sinon
-        .stub()
-        .yields()
-    })
-
-    it('should send the email', async function () {
-      this.req = {
-        body: {
-          email: 'test@example.com',
-        },
-      }
-      await this.UserEmailsController.sendReconfirmation(
-        this.req,
-        this.res,
-        this.next
-      )
-      expect(
-        this.UserEmailsConfirmationHandler.promises.sendReconfirmationEmail
-      ).to.have.been.calledOnce
-    })
-
-    it('should return 422 if email not valid', function (done) {
-      this.req = {
-        body: {},
-      }
-      this.UserEmailsController.resendConfirmation(
-        this.req,
-        this.res,
-        this.next
-      )
-      expect(this.UserEmailsConfirmationHandler.sendConfirmationEmail).to.not
-        .have.been.called
-      expect(this.res.sendStatus.lastCall.args[0]).to.equal(422)
-      done()
-    })
-
-    describe('email on another user account', function () {
-      beforeEach(function () {
-        this.UserGetter.promises.getUserByAnyEmail.resolves({
-          _id: 'another-user-id',
-        })
-      })
-      it('should return 422', async function () {
-        this.req = {
-          body: {
-            email: 'test@example.com',
-          },
-        }
-        await this.UserEmailsController.resendConfirmation(
-          this.req,
-          this.res,
-          this.next
-        )
-        expect(this.UserEmailsConfirmationHandler.sendConfirmationEmail).to.not
-          .have.been.called
-        expect(this.res.sendStatus.lastCall.args[0]).to.equal(422)
-      })
-    })
-  })
-
   describe('sendReconfirmation', function () {
     beforeEach(function () {
       this.res.sendStatus = sinon.stub()