Create User.emails field for newly created users in launchpad (#2083)

GitOrigin-RevId: b6cfad25eeba21294f70769e11c3e3fa825f93aa
This commit is contained in:
Miguel Serrano 2019-08-19 17:06:27 +02:00 committed by sharelatex
parent 9386bdeaff
commit 8c55989166
2 changed files with 60 additions and 28 deletions

View file

@ -165,7 +165,10 @@ module.exports = LaunchpadController = {
return User.update(
{ _id: user._id },
{ $set: { isAdmin: true } },
{
$set: { isAdmin: true },
emails: [{ email }]
},
function(err) {
if (err != null) {
logger.warn(
@ -219,9 +222,15 @@ module.exports = LaunchpadController = {
logger.log({ user_id: user._id }, 'making user an admin')
const proceed = () =>
User.update({ _id: user._id }, { $set: { isAdmin: true } }, function(
err
) {
User.update(
{ _id: user._id },
{
$set: {
isAdmin: true,
emails: [{ email }]
}
},
function(err) {
if (err != null) {
logger.err(
{ user_id: user._id, err },
@ -243,7 +252,8 @@ module.exports = LaunchpadController = {
email: user.email,
created: Date.now()
})
})
}
)
if (
Settings.overleaf != null &&

View file

@ -366,7 +366,15 @@ describe('LaunchpadController', function() {
it('should have updated the user to make them an admin', function() {
this.User.update.callCount.should.equal(1)
return this.User.update
.calledWith({ _id: this.user._id }, { $set: { isAdmin: true } })
.calledWithMatch(
{ _id: this.user._id },
{
$set: {
isAdmin: true,
emails: [{ email: this.user.email }]
}
}
)
.should.equal(true)
})
@ -677,7 +685,15 @@ describe('LaunchpadController', function() {
it('should have updated the user to make them an admin', function() {
return this.User.update
.calledWith({ _id: this.user._id }, { $set: { isAdmin: true } })
.calledWith(
{ _id: this.user._id },
{
$set: {
isAdmin: true,
emails: [{ email: this.user.email }]
}
}
)
.should.equal(true)
})
@ -752,7 +768,13 @@ describe('LaunchpadController', function() {
it('should have updated the user to make them an admin', function() {
this.User.update.callCount.should.equal(1)
return this.User.update
.calledWith({ _id: this.user._id }, { $set: { isAdmin: true } })
.calledWith(
{ _id: this.user._id },
{
$set: { isAdmin: true },
emails: [{ email: this.user.email }]
}
)
.should.equal(true)
})