Merge pull request #12342 from overleaf/jk-password-ux-please-use-another-password

[web] Password UX: 'Please use another password'

GitOrigin-RevId: ca9b26cbcf2dabb27c716da314764ee40ffc83dd
This commit is contained in:
June Kelly
2023-04-11 14:16:51 +01:00
committed by Copybot
parent 36413f0fa3
commit c169797795
10 changed files with 137 additions and 45 deletions
@@ -61,6 +61,9 @@ describe('UserController', function () {
authenticate: sinon.stub(),
setUserPassword: sinon.stub(),
},
getMessageForInvalidPasswordError: sinon
.stub()
.returns({ type: 'error', key: 'some-key' }),
}
this.UserUpdater = {
changeEmailAddress: sinon.stub(),
@@ -771,18 +774,21 @@ describe('UserController', function () {
// .returns({ message: 'validation-error' })
const err = new Error('bad')
err.name = 'InvalidPasswordError'
const message = {
type: 'error',
key: 'some-message-key',
}
this.AuthenticationManager.getMessageForInvalidPasswordError.returns(
message
)
this.AuthenticationManager.promises.setUserPassword.rejects(err)
this.AuthenticationManager.promises.authenticate.resolves({})
this.req.body = {
newPassword1: 'newpass',
newPassword2: 'newpass',
}
this.HttpErrorHandler.badRequest.callsFake(() => {
expect(this.HttpErrorHandler.badRequest).to.have.been.calledWith(
this.req,
this.res,
err.message
)
this.res.json.callsFake(result => {
expect(result.message).to.deep.equal(message)
this.AuthenticationManager.promises.setUserPassword.callCount.should.equal(
1
)