Skip to content
This repository was archived by the owner on May 6, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/coffee/LaunchpadController.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module.exports = LaunchpadController =
logger.err {user_id: user._id, err}, "error setting user to admin"
return next(err)

AuthenticationController._setRedirectInSession(req, '/launchpad')
AuthenticationController.setRedirectInSession(req, '/launchpad')
logger.log {email, user_id: user._id, authMethod}, "created first admin account"

return res.json {redir: '/launchpad', email: email}
Expand Down Expand Up @@ -133,7 +133,7 @@ module.exports = LaunchpadController =
logger.err {user_id: user._id, err}, "error setting user to admin"
return next(err)

AuthenticationController._setRedirectInSession(req, '/launchpad')
AuthenticationController.setRedirectInSession(req, '/launchpad')
logger.log {email, user_id: user._id}, "created first admin account"
res.json
redir: ''
Expand Down
42 changes: 21 additions & 21 deletions test/unit/coffee/LaunchpadControllerTests.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe 'LaunchpadController', ->
email: @email
@UserRegistrationHandler.registerNewUser = sinon.stub().callsArgWith(1, null, @user)
@User.update = sinon.stub().callsArgWith(2, null)
@AuthenticationController._setRedirectInSession = sinon.stub()
@AuthenticationController.setRedirectInSession = sinon.stub()
@res.json = sinon.stub()
@next = sinon.stub()
@LaunchpadController.registerAdmin(@req, @res, @next)
Expand All @@ -224,8 +224,8 @@ describe 'LaunchpadController', ->
@User.update.calledWith({_id: @user._id}, {$set: {isAdmin: true}}).should.equal true

it 'should have set a redirect in session', ->
@AuthenticationController._setRedirectInSession.callCount.should.equal 1
@AuthenticationController._setRedirectInSession.calledWith(@req, '/launchpad').should.equal true
@AuthenticationController.setRedirectInSession.callCount.should.equal 1
@AuthenticationController.setRedirectInSession.calledWith(@req, '/launchpad').should.equal true


describe 'when no email is supplied', ->
Expand All @@ -240,7 +240,7 @@ describe 'LaunchpadController', ->
email: @email
@UserRegistrationHandler.registerNewUser = sinon.stub()
@User.update = sinon.stub()
@AuthenticationController._setRedirectInSession = sinon.stub()
@AuthenticationController.setRedirectInSession = sinon.stub()
@res.sendStatus = sinon.stub()
@next = sinon.stub()
@LaunchpadController.registerAdmin(@req, @res, @next)
Expand All @@ -267,7 +267,7 @@ describe 'LaunchpadController', ->
email: @email
@UserRegistrationHandler.registerNewUser = sinon.stub()
@User.update = sinon.stub()
@AuthenticationController._setRedirectInSession = sinon.stub()
@AuthenticationController.setRedirectInSession = sinon.stub()
@res.sendStatus = sinon.stub()
@next = sinon.stub()
@LaunchpadController.registerAdmin(@req, @res, @next)
Expand All @@ -294,7 +294,7 @@ describe 'LaunchpadController', ->
email: @email
@UserRegistrationHandler.registerNewUser = sinon.stub()
@User.update = sinon.stub()
@AuthenticationController._setRedirectInSession = sinon.stub()
@AuthenticationController.setRedirectInSession = sinon.stub()
@res.sendStatus = sinon.stub()
@next = sinon.stub()
@LaunchpadController.registerAdmin(@req, @res, @next)
Expand All @@ -318,7 +318,7 @@ describe 'LaunchpadController', ->
email: @email
@UserRegistrationHandler.registerNewUser = sinon.stub()
@User.update = sinon.stub()
@AuthenticationController._setRedirectInSession = sinon.stub()
@AuthenticationController.setRedirectInSession = sinon.stub()
@res.sendStatus = sinon.stub()
@next = sinon.stub()
@LaunchpadController.registerAdmin(@req, @res, @next)
Expand All @@ -345,7 +345,7 @@ describe 'LaunchpadController', ->
email: @email
@UserRegistrationHandler.registerNewUser = sinon.stub().callsArgWith(1, new Error('woops'))
@User.update = sinon.stub()
@AuthenticationController._setRedirectInSession = sinon.stub()
@AuthenticationController.setRedirectInSession = sinon.stub()
@res.json = sinon.stub()
@next = sinon.stub()
@LaunchpadController.registerAdmin(@req, @res, @next)
Expand Down Expand Up @@ -376,7 +376,7 @@ describe 'LaunchpadController', ->
email: @email
@UserRegistrationHandler.registerNewUser = sinon.stub().callsArgWith(1, null, @user)
@User.update = sinon.stub().callsArgWith(2, new Error('woops'))
@AuthenticationController._setRedirectInSession = sinon.stub()
@AuthenticationController.setRedirectInSession = sinon.stub()
@res.json = sinon.stub()
@next = sinon.stub()
@LaunchpadController.registerAdmin(@req, @res, @next)
Expand Down Expand Up @@ -406,7 +406,7 @@ describe 'LaunchpadController', ->
email: @email
@UserRegistrationHandler.registerNewUser = sinon.stub().callsArgWith(1, null, @user)
@User.update = sinon.stub().callsArgWith(2, null)
@AuthenticationController._setRedirectInSession = sinon.stub()
@AuthenticationController.setRedirectInSession = sinon.stub()
@SharelatexAuthController._createBackingAccountIfNeeded = sinon.stub().callsArgWith(2, null)
@UserGetter.getUser = sinon.stub().callsArgWith(1, null, {_id: '1234'})
@res.json = sinon.stub()
Expand All @@ -431,8 +431,8 @@ describe 'LaunchpadController', ->
@User.update.calledWith({_id: @user._id}, {$set: {isAdmin: true}}).should.equal true

it 'should have set a redirect in session', ->
@AuthenticationController._setRedirectInSession.callCount.should.equal 1
@AuthenticationController._setRedirectInSession.calledWith(@req, '/launchpad').should.equal true
@AuthenticationController.setRedirectInSession.callCount.should.equal 1
@AuthenticationController.setRedirectInSession.calledWith(@req, '/launchpad').should.equal true


describe 'registerExternalAuthAdmin', ->
Expand All @@ -453,7 +453,7 @@ describe 'LaunchpadController', ->
email: @email
@UserRegistrationHandler.registerNewUser = sinon.stub().callsArgWith(1, null, @user)
@User.update = sinon.stub().callsArgWith(2, null)
@AuthenticationController._setRedirectInSession = sinon.stub()
@AuthenticationController.setRedirectInSession = sinon.stub()
@res.json = sinon.stub()
@next = sinon.stub()
@LaunchpadController.registerExternalAuthAdmin('ldap')(@req, @res, @next)
Expand All @@ -476,8 +476,8 @@ describe 'LaunchpadController', ->
@User.update.calledWith({_id: @user._id}, {$set: {isAdmin: true}}).should.equal true

it 'should have set a redirect in session', ->
@AuthenticationController._setRedirectInSession.callCount.should.equal 1
@AuthenticationController._setRedirectInSession.calledWith(@req, '/launchpad').should.equal true
@AuthenticationController.setRedirectInSession.callCount.should.equal 1
@AuthenticationController.setRedirectInSession.calledWith(@req, '/launchpad').should.equal true

describe 'when the authMethod is invalid', ->
beforeEach ->
Expand All @@ -489,7 +489,7 @@ describe 'LaunchpadController', ->
email: @email
@UserRegistrationHandler.registerNewUser = sinon.stub()
@User.update = sinon.stub()
@AuthenticationController._setRedirectInSession = sinon.stub()
@AuthenticationController.setRedirectInSession = sinon.stub()
@res.sendStatus = sinon.stub()
@next = sinon.stub()
@LaunchpadController.registerExternalAuthAdmin('NOTAVALIDAUTHMETHOD')(@req, @res, @next)
Expand All @@ -514,7 +514,7 @@ describe 'LaunchpadController', ->
email: @email
@UserRegistrationHandler.registerNewUser = sinon.stub()
@User.update = sinon.stub()
@AuthenticationController._setRedirectInSession = sinon.stub()
@AuthenticationController.setRedirectInSession = sinon.stub()
@res.sendStatus = sinon.stub()
@next = sinon.stub()
@LaunchpadController.registerExternalAuthAdmin('ldap')(@req, @res, @next)
Expand All @@ -539,7 +539,7 @@ describe 'LaunchpadController', ->
email: @email
@UserRegistrationHandler.registerNewUser = sinon.stub()
@User.update = sinon.stub()
@AuthenticationController._setRedirectInSession = sinon.stub()
@AuthenticationController.setRedirectInSession = sinon.stub()
@res.sendStatus = sinon.stub()
@next = sinon.stub()
@LaunchpadController.registerExternalAuthAdmin('ldap')(@req, @res, @next)
Expand All @@ -561,7 +561,7 @@ describe 'LaunchpadController', ->
email: @email
@UserRegistrationHandler.registerNewUser = sinon.stub()
@User.update = sinon.stub()
@AuthenticationController._setRedirectInSession = sinon.stub()
@AuthenticationController.setRedirectInSession = sinon.stub()
@res.sendStatus = sinon.stub()
@next = sinon.stub()
@LaunchpadController.registerExternalAuthAdmin('ldap')(@req, @res, @next)
Expand All @@ -586,7 +586,7 @@ describe 'LaunchpadController', ->
email: @email
@UserRegistrationHandler.registerNewUser = sinon.stub().callsArgWith(1, new Error('woops'))
@User.update = sinon.stub()
@AuthenticationController._setRedirectInSession = sinon.stub()
@AuthenticationController.setRedirectInSession = sinon.stub()
@res.json = sinon.stub()
@next = sinon.stub()
@LaunchpadController.registerExternalAuthAdmin('ldap')(@req, @res, @next)
Expand Down Expand Up @@ -617,7 +617,7 @@ describe 'LaunchpadController', ->
email: @email
@UserRegistrationHandler.registerNewUser = sinon.stub().callsArgWith(1, null, @user)
@User.update = sinon.stub().callsArgWith(2, new Error('woops'))
@AuthenticationController._setRedirectInSession = sinon.stub()
@AuthenticationController.setRedirectInSession = sinon.stub()
@res.json = sinon.stub()
@next = sinon.stub()
@LaunchpadController.registerExternalAuthAdmin('ldap')(@req, @res, @next)
Expand Down