mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Create User.emails field for newly created users in launchpad (#2083)
GitOrigin-RevId: b6cfad25eeba21294f70769e11c3e3fa825f93aa
This commit is contained in:
parent
9386bdeaff
commit
8c55989166
2 changed files with 60 additions and 28 deletions
|
@ -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,31 +222,38 @@ 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
|
||||
) {
|
||||
if (err != null) {
|
||||
logger.err(
|
||||
{ user_id: user._id, err },
|
||||
'error setting user to admin'
|
||||
)
|
||||
return next(err)
|
||||
}
|
||||
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()
|
||||
})
|
||||
})
|
||||
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()
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
if (
|
||||
Settings.overleaf != null &&
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue