diff --git a/services/web/app/src/Features/User/UserEmailsConfirmationHandler.js b/services/web/app/src/Features/User/UserEmailsConfirmationHandler.js index b349c97848..e44ab27d5f 100644 --- a/services/web/app/src/Features/User/UserEmailsConfirmationHandler.js +++ b/services/web/app/src/Features/User/UserEmailsConfirmationHandler.js @@ -65,28 +65,6 @@ async function sendConfirmationCode(email, welcomeUser) { } } -async function sendReconfirmationEmail(userId, email) { - email = EmailHelper.parseEmail(email) - if (!email) { - throw new Error('invalid email') - } - - const data = { user_id: userId, email } - const token = await OneTimeTokenHandler.promises.getNewToken( - TOKEN_USE, - data, - { expiresIn: TOKEN_EXPIRY_IN_S } - ) - - const emailOptions = { - to: email, - confirmEmailUrl: `${settings.siteUrl}/user/emails/confirm?token=${token}`, - sendingUser_id: userId, - } - - await EmailHandler.promises.sendEmail('reconfirmEmail', emailOptions) -} - async function confirmEmailFromToken(req, token) { const { data } = await OneTimeTokenHandler.promises.peekValueFromToken( TOKEN_USE, @@ -123,9 +101,6 @@ async function confirmEmailFromToken(req, token) { const UserEmailsConfirmationHandler = { sendConfirmationEmail, - - sendReconfirmationEmail: callbackify(sendReconfirmationEmail), - confirmEmailFromToken: callbackify(confirmEmailFromToken), } @@ -133,7 +108,6 @@ UserEmailsConfirmationHandler.promises = { sendConfirmationEmail: promisify(sendConfirmationEmail), confirmEmailFromToken, sendConfirmationCode, - sendReconfirmationEmail, } module.exports = UserEmailsConfirmationHandler diff --git a/services/web/app/src/Features/User/UserEmailsController.js b/services/web/app/src/Features/User/UserEmailsController.js index 0197615bbf..1506443b9f 100644 --- a/services/web/app/src/Features/User/UserEmailsController.js +++ b/services/web/app/src/Features/User/UserEmailsController.js @@ -640,8 +640,6 @@ const UserEmailsController = { ) }, - sendReconfirmation: expressify(sendReconfirmation), - sendExistingEmailConfirmationCode: expressify( sendExistingEmailConfirmationCode ), diff --git a/services/web/frontend/stories/project-list/helpers/emails.ts b/services/web/frontend/stories/project-list/helpers/emails.ts index 9f21370736..4fadd3ca11 100644 --- a/services/web/frontend/stories/project-list/helpers/emails.ts +++ b/services/web/frontend/stories/project-list/helpers/emails.ts @@ -62,9 +62,6 @@ export function errorsMocks(fetchMock: FetchMock) { 500, { delay: MOCK_DELAY } ) - fetchMock.post(/\/user\/emails\/send-reconfirmation/, 500, { - delay: MOCK_DELAY, - }) } export function setInstitutionMeta(institutionData: Partial) { @@ -119,7 +116,4 @@ export function reconfirmAffiliationSetupMocks(fetchMock: FetchMock) { totalSize: 0, }, }) - fetchMock.post(/\/user\/emails\/send-reconfirmation/, 200, { - delay: MOCK_DELAY, - }) } diff --git a/services/web/test/unit/src/User/UserEmailsControllerTests.js b/services/web/test/unit/src/User/UserEmailsControllerTests.js index 395b57f28c..b82229ad69 100644 --- a/services/web/test/unit/src/User/UserEmailsControllerTests.js +++ b/services/web/test/unit/src/User/UserEmailsControllerTests.js @@ -93,7 +93,6 @@ describe('UserEmailsController', function () { { promises: { sendConfirmationEmail: sinon.stub().resolves(), - sendReconfirmationEmail: sinon.stub(), }, }), '../Institutions/InstitutionsAPI': this.InstitutionsAPI, @@ -607,69 +606,6 @@ describe('UserEmailsController', function () { }) }) - describe('sendReconfirmation', function () { - beforeEach(function () { - this.res.sendStatus = sinon.stub() - this.UserGetter.promises.getUserByAnyEmail.resolves({ - _id: this.user._id, - }) - this.EmailHelper.parseEmail.returnsArg(0) - }) - 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 400 if email not valid', function (done) { - this.req = { - body: {}, - } - this.UserEmailsController.sendReconfirmation( - this.req, - this.res, - this.next - ) - expect( - this.UserEmailsConfirmationHandler.promises.sendReconfirmationEmail - ).to.not.have.been.called - expect(this.res.sendStatus.lastCall.args[0]).to.equal(400) - 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.sendReconfirmation( - this.req, - this.res, - this.next - ) - expect( - this.UserEmailsConfirmationHandler.promises.sendReconfirmationEmail - ).to.not.have.been.called - expect(this.res.sendStatus.lastCall.args[0]).to.equal(422) - }) - }) - }) - describe('sendExistingEmailConfirmationCode', function () { beforeEach(function () { this.email = 'existing-email@example.com'