[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
This commit is contained in:
Antoine Clausse
2025-07-29 14:56:56 +02:00
committed by Copybot
parent ec69641649
commit 535a9774ef
4 changed files with 0 additions and 105 deletions
@@ -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(
-8
View File
@@ -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(),
@@ -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() {
@@ -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()