Merge pull request #13584 from overleaf/bg-managed-users-block-delete-own-account

block account deletion by managed users

GitOrigin-RevId: 895e5e31951bf60cfade4cf7acc3ef330df214e6
This commit is contained in:
Brian Gough
2023-07-05 09:53:48 +01:00
committed by Copybot
parent 7f7f48ce91
commit b111e5a59f
8 changed files with 84 additions and 9 deletions
@@ -928,12 +928,18 @@ describe('UserController', function () {
]
this.Features.hasFeature.withArgs('affiliations').returns(true)
this.req.query.ensureAffiliation = true
this.req.assertPermission = sinon.stub()
await this.UserController.promises.ensureAffiliationMiddleware(
this.req,
this.res,
this.next
)
})
it('should check the user has permission', function () {
expect(this.req.assertPermission).to.have.been.calledWith(
'add-affiliation'
)
})
it('should unflag the emails but not confirm', function () {
expect(
this.UserUpdater.promises.addAffiliationForNewUser
@@ -960,12 +966,18 @@ describe('UserController', function () {
]
this.Features.hasFeature.withArgs('affiliations').returns(true)
this.req.query.ensureAffiliation = true
this.req.assertPermission = sinon.stub()
await this.UserController.promises.ensureAffiliationMiddleware(
this.req,
this.res,
this.next
)
})
it('should check the user has permission', function () {
expect(this.req.assertPermission).to.have.been.calledWith(
'add-affiliation'
)
})
it('should add affiliation to v1, unflag and confirm on v2', function () {
expect(this.UserUpdater.promises.addAffiliationForNewUser).to.have.not
.been.called
@@ -992,12 +1004,18 @@ describe('UserController', function () {
]
this.Features.hasFeature.withArgs('affiliations').returns(true)
this.req.query.ensureAffiliation = true
this.req.assertPermission = sinon.stub()
await this.UserController.promises.ensureAffiliationMiddleware(
this.req,
this.res,
this.next
)
})
it('should check the user has permission', function () {
expect(this.req.assertPermission).to.have.been.calledWith(
'add-affiliation'
)
})
it('should return the error', function () {
expect(this.next).to.be.calledWith(sinon.match.instanceOf(Error))
})