Remove endpoint /user/emails/send-reconfirmation (#27423)

GitOrigin-RevId: bd96d749175248cba83eb07c00dab7e7a9f819da
This commit is contained in:
Antoine Clausse
2025-07-29 15:02:11 +02:00
committed by Copybot
parent 924aa6db23
commit c9c26f7f52
4 changed files with 0 additions and 98 deletions

View File

@@ -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

View File

@@ -640,8 +640,6 @@ const UserEmailsController = {
)
},
sendReconfirmation: expressify(sendReconfirmation),
sendExistingEmailConfirmationCode: expressify(
sendExistingEmailConfirmationCode
),

View File

@@ -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<Institution>) {
@@ -119,7 +116,4 @@ export function reconfirmAffiliationSetupMocks(fetchMock: FetchMock) {
totalSize: 0,
},
})
fetchMock.post(/\/user\/emails\/send-reconfirmation/, 200, {
delay: MOCK_DELAY,
})
}

View File

@@ -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'