diff --git a/services/web/app/src/Features/User/UserEmailsController.js b/services/web/app/src/Features/User/UserEmailsController.js index 7f235cead3..0197615bbf 100644 --- a/services/web/app/src/Features/User/UserEmailsController.js +++ b/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( diff --git a/services/web/app/src/router.mjs b/services/web/app/src/router.mjs index 558d1e572e..82b0bacbfa 100644 --- a/services/web/app/src/router.mjs +++ b/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(), diff --git a/services/web/frontend/stories/project-list/helpers/emails.ts b/services/web/frontend/stories/project-list/helpers/emails.ts index 83c09fd527..9f21370736 100644 --- a/services/web/frontend/stories/project-list/helpers/emails.ts +++ b/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() { diff --git a/services/web/test/unit/src/User/UserEmailsControllerTests.js b/services/web/test/unit/src/User/UserEmailsControllerTests.js index e64629e88a..395b57f28c 100644 --- a/services/web/test/unit/src/User/UserEmailsControllerTests.js +++ b/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()