Merge pull request #2668 from overleaf/jpa-fix-launchpad

[launchpad] remove the broken v1 registration

GitOrigin-RevId: 1a07076c0e7c0a24fb5aa6fb79ebbff9be4b9bba
This commit is contained in:
Eric Mc Sween 2020-03-16 07:31:20 -04:00 committed by Copybot
parent 9f3b2d2cdc
commit 1749ab7099
2 changed files with 28 additions and 67 deletions

View file

@ -221,67 +221,38 @@ module.exports = LaunchpadController = {
}
logger.log({ user_id: user._id }, 'making user an admin')
const proceed = () =>
User.update(
{ _id: user._id },
{
$set: {
isAdmin: true,
emails: [{ email }]
}
},
function(err) {
if (err != null) {
logger.err(
{ user_id: user._id, err },
'error setting user to admin'
)
return next(err)
}
AuthenticationController.setRedirectInSession(req, '/launchpad')
logger.log(
{ email, user_id: user._id },
'created first admin account'
)
return res.json({
redir: '',
id: user._id.toString(),
first_name: user.first_name,
last_name: user.last_name,
email: user.email,
created: Date.now()
})
User.update(
{ _id: user._id },
{
$set: {
isAdmin: true,
emails: [{ email }]
}
)
if (
Settings.overleaf != null &&
Settings.createV1AccountOnLogin != null
) {
logger.log(
{ user_id: user._id },
'Creating backing account in v1 for new admin user'
)
const SharelatexAuthController = require('../../../overleaf-integration/app/src/SharelatexAuth/SharelatexAuthController')
return UserGetter.getUser(user._id, function(err, user) {
},
function(err) {
if (err != null) {
logger.err(
{ user_id: user._id, err },
'error setting user to admin'
)
return next(err)
}
return SharelatexAuthController._createBackingAccountIfNeeded(
user,
req,
function(err) {
if (err != null) {
return next(err)
}
return proceed()
}
AuthenticationController.setRedirectInSession(req, '/launchpad')
logger.log(
{ email, user_id: user._id },
'created first admin account'
)
})
} else {
return proceed()
}
return res.json({
redir: '',
id: user._id.toString(),
first_name: user.first_name,
last_name: user.last_name,
email: user.email,
created: Date.now()
})
}
)
})
})
}

View file

@ -48,8 +48,7 @@ describe('LaunchpadController', function() {
'../../../../app/src/Features/Email/EmailHandler': (this.EmailHandler = {}),
'../../../../app/src/Features/User/UserGetter': (this.UserGetter = {}),
'../../../../app/src/models/User': { User: this.User },
'../../../../app/src/Features/Authentication/AuthenticationController': (this.AuthenticationController = {}),
'../../../overleaf-integration/app/src/SharelatexAuth/SharelatexAuthController': (this.SharelatexAuthController = {})
'../../../../app/src/Features/Authentication/AuthenticationController': (this.AuthenticationController = {})
}
})
@ -646,9 +645,6 @@ describe('LaunchpadController', function() {
.callsArgWith(1, null, this.user)
this.User.update = sinon.stub().callsArgWith(2, null)
this.AuthenticationController.setRedirectInSession = sinon.stub()
this.SharelatexAuthController._createBackingAccountIfNeeded = sinon
.stub()
.callsArgWith(2, null)
this.UserGetter.getUser = sinon
.stub()
.callsArgWith(1, null, { _id: '1234' })
@ -677,12 +673,6 @@ describe('LaunchpadController', function() {
.should.equal(true)
})
it('should have created a backing account for the user', function() {
return this.SharelatexAuthController._createBackingAccountIfNeeded.callCount.should.equal(
1
)
})
it('should have updated the user to make them an admin', function() {
return this.User.update
.calledWith(