[misc] move /user/activate into a module (#2962)
* [misc] move /user/activate into a module Co-Authored-By: Nate Stemen <nate.stemen@overleaf.com> * [misc] setup copybara for the new user-activate module * [misc] move the /user/activate route behind a feature flag ...which is by default enabled. Co-authored-by: Nate Stemen <nate.stemen@overleaf.com> GitOrigin-RevId: 87fc5ae869a7e282ffdbeea0ff7b7c55b8b9b31b
This commit is contained in:
committed by
Copybot
co-authored by
Nate Stemen
parent
c660497859
commit
53927bca95
@@ -292,57 +292,4 @@ describe('UserPagesController', function() {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('activateAccountPage', function() {
|
||||
beforeEach(function() {
|
||||
this.UserGetter.getUser = sinon.stub().callsArgWith(2, null, this.user)
|
||||
this.req.query.user_id = this.user_id
|
||||
return (this.req.query.token = this.token = 'mock-token-123')
|
||||
})
|
||||
|
||||
it('should 404 without a user_id', function(done) {
|
||||
delete this.req.query.user_id
|
||||
this.ErrorController.notFound = () => done()
|
||||
return this.UserPagesController.activateAccountPage(this.req, this.res)
|
||||
})
|
||||
|
||||
it('should 404 without a token', function(done) {
|
||||
delete this.req.query.token
|
||||
this.ErrorController.notFound = () => done()
|
||||
return this.UserPagesController.activateAccountPage(this.req, this.res)
|
||||
})
|
||||
|
||||
it('should 404 without a valid user_id', function(done) {
|
||||
this.UserGetter.getUser = sinon.stub().callsArgWith(2, null, null)
|
||||
this.ErrorController.notFound = () => done()
|
||||
return this.UserPagesController.activateAccountPage(this.req, this.res)
|
||||
})
|
||||
|
||||
it('should 403 for complex user_id', function(done) {
|
||||
this.ErrorController.forbidden = () => done()
|
||||
this.req.query.user_id = { first_name: 'X' }
|
||||
return this.UserPagesController.activateAccountPage(this.req, this.res)
|
||||
})
|
||||
|
||||
it('should redirect activated users to login', function(done) {
|
||||
this.user.loginCount = 1
|
||||
this.res.redirect = url => {
|
||||
this.UserGetter.getUser.calledWith(this.user_id).should.equal(true)
|
||||
url.should.equal('/login')
|
||||
return done()
|
||||
}
|
||||
return this.UserPagesController.activateAccountPage(this.req, this.res)
|
||||
})
|
||||
|
||||
it('render the activation page if the user has not logged in before', function(done) {
|
||||
this.user.loginCount = 0
|
||||
this.res.render = (page, opts) => {
|
||||
page.should.equal('user/activate')
|
||||
opts.email.should.equal(this.user.email)
|
||||
opts.token.should.equal(this.token)
|
||||
return done()
|
||||
}
|
||||
return this.UserPagesController.activateAccountPage(this.req, this.res)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user