mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-04 22:59:01 +02:00
[web] Send security alert email when secondary is added (#23657)
* [web] Send security alert email when secondary is added * [web] Add test: checkSecondaryEmailConfirmationCode - sends a security alert email * Move `_sendSecurityAlertEmail` before `addEmailAddress` GitOrigin-RevId: 8d9c496fffd953871e03d8c7f011c42459eeb0bc
This commit is contained in:
@@ -409,6 +409,31 @@ describe('UserEmailsController', function () {
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it('sends a security alert email', async function () {
|
||||
this.req.session.pendingSecondaryEmail = {
|
||||
confirmCode: '123456',
|
||||
email: this.newEmail,
|
||||
confirmCodeExpiresTimestamp: new Date(Math.max),
|
||||
affiliationOptions: {},
|
||||
}
|
||||
this.req.body.code = '123456'
|
||||
|
||||
await this.UserEmailsController.checkSecondaryEmailConfirmationCode(
|
||||
this.req,
|
||||
{
|
||||
json: sinon.stub().resolves(),
|
||||
}
|
||||
)
|
||||
|
||||
const emailCall = this.EmailHandler.promises.sendEmail.getCall(0)
|
||||
expect(emailCall.args[0]).to.equal('securityAlert')
|
||||
expect(emailCall.args[1].to).to.equal(this.user.email)
|
||||
expect(emailCall.args[1].actionDescribed).to.contain(
|
||||
'a secondary email address'
|
||||
)
|
||||
expect(emailCall.args[1].message[0]).to.contain(this.newEmail)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with an invalid confirmation code', function () {
|
||||
|
||||
Reference in New Issue
Block a user