mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Add method to update user references
This commit is contained in:
parent
09ddc75126
commit
259d690f7c
1 changed files with 19 additions and 4 deletions
|
@ -43,6 +43,21 @@ module.exports = SubscriptionGroupHandler =
|
||||||
removeEmailInviteFromGroup: (adminUser_id, email, callback) ->
|
removeEmailInviteFromGroup: (adminUser_id, email, callback) ->
|
||||||
SubscriptionUpdater.removeEmailInviteFromGroup adminUser_id, email, callback
|
SubscriptionUpdater.removeEmailInviteFromGroup adminUser_id, email, callback
|
||||||
|
|
||||||
|
|
||||||
|
replaceUserReferencesInGroups: (oldId, newId, callback) ->
|
||||||
|
Subscription.update {admin_id: userStubId}, {admin_id: slUserId}, (error) ->
|
||||||
|
callback(error) if error?
|
||||||
|
|
||||||
|
# Mongo won't let us pull and addToSet in the same query, so do it in
|
||||||
|
# two. Note we need to add first, since the query is based on the old user.
|
||||||
|
query = {member_ids: userStubId}
|
||||||
|
addNewUserUpdate = $addToSet: {member_ids: slUserId}
|
||||||
|
removeOldUserUpdate = $pull: {member_ids: userStubId}
|
||||||
|
|
||||||
|
Subscription.update query, addNewUserUpdate, { multi: true }, (error) ->
|
||||||
|
return callback(error) if error?
|
||||||
|
Subscription.update query, removeOldUserUpdate, { multi: true }, callback
|
||||||
|
|
||||||
getPopulatedListOfMembers: (adminUser_id, callback)->
|
getPopulatedListOfMembers: (adminUser_id, callback)->
|
||||||
SubscriptionLocator.getUsersSubscription adminUser_id, (err, subscription)->
|
SubscriptionLocator.getUsersSubscription adminUser_id, (err, subscription)->
|
||||||
users = []
|
users = []
|
||||||
|
|
Loading…
Reference in a new issue