mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
add more error logging to group handler
This commit is contained in:
parent
1e1f57a80b
commit
103bb1c88f
3 changed files with 23 additions and 4 deletions
|
@ -15,6 +15,9 @@ module.exports =
|
|||
newEmail = req.body.email
|
||||
logger.log adminUserId:adminUserId, newEmail:newEmail, "adding user to group subscription"
|
||||
SubscriptionGroupHandler.addUserToGroup adminUserId, newEmail, (err, user)->
|
||||
if err?
|
||||
logger.err err:err, newEmail:newEmail, adminUserId:adminUserId, "error adding user from group"
|
||||
return res.sendStatus 500
|
||||
result =
|
||||
user:user
|
||||
if err and err.limitReached
|
||||
|
@ -25,14 +28,20 @@ module.exports =
|
|||
adminUserId = req.session.user._id
|
||||
userToRemove_id = req.params.user_id
|
||||
logger.log adminUserId:adminUserId, userToRemove_id:userToRemove_id, "removing user from group subscription"
|
||||
SubscriptionGroupHandler.removeUserFromGroup adminUserId, userToRemove_id, ->
|
||||
SubscriptionGroupHandler.removeUserFromGroup adminUserId, userToRemove_id, (err)->
|
||||
if err?
|
||||
logger.err err:err, adminUserId:adminUserId, userToRemove_id:userToRemove_id, "error removing user from group"
|
||||
return res.sendStatus 500
|
||||
res.send()
|
||||
|
||||
removeSelfFromGroup: (req, res)->
|
||||
adminUserId = req.query.admin_user_id
|
||||
userToRemove_id = req.session.user._id
|
||||
logger.log adminUserId:adminUserId, userToRemove_id:userToRemove_id, "removing user from group subscription after self request"
|
||||
SubscriptionGroupHandler.removeUserFromGroup adminUserId, userToRemove_id, ->
|
||||
SubscriptionGroupHandler.removeUserFromGroup adminUserId, userToRemove_id, (err)->
|
||||
if err?
|
||||
logger.err err:err, userToRemove_id:userToRemove_id, adminUserId:adminUserId, "error removing self from group"
|
||||
return res.sendStatus 500
|
||||
res.send()
|
||||
|
||||
renderSubscriptionGroupAdminPage: (req, res)->
|
||||
|
|
|
@ -16,9 +16,14 @@ module.exports = SubscriptionGroupHandler =
|
|||
addUserToGroup: (subscription, newEmail, callback)->
|
||||
UserCreator.getUserOrCreateHoldingAccount newEmail, (err, user)->
|
||||
LimitationsManager.hasGroupMembersLimitReached subscription.admin_id, (err, limitReached)->
|
||||
if err?
|
||||
return callback(err)
|
||||
if limitReached
|
||||
return callback(limitReached:limitReached)
|
||||
SubscriptionUpdater.addUserToGroup subscription.admin_id, user._id, (err)->
|
||||
if err?
|
||||
logger.err err:err, "error adding user to group"
|
||||
return callback(err)
|
||||
NotificationsBuilder.groupPlan(user, {subscription_id:subscription._id}).read()
|
||||
userViewModel = buildUserViewModel(user)
|
||||
callback(err, userViewModel)
|
||||
|
|
|
@ -32,6 +32,9 @@ module.exports =
|
|||
insertOperation =
|
||||
"$addToSet": {member_ids:user_id}
|
||||
Subscription.findAndModify searchOps, insertOperation, (err, subscription)->
|
||||
if err?
|
||||
logger.err err:err, searchOps:searchOps, insertOperation:insertOperation, "error findy and modify add user to group"
|
||||
return callback(err)
|
||||
UserFeaturesUpdater.updateFeatures user_id, subscription.planCode, callback
|
||||
|
||||
removeUserFromGroup: (adminUser_id, user_id, callback)->
|
||||
|
@ -39,10 +42,12 @@ module.exports =
|
|||
admin_id: adminUser_id
|
||||
removeOperation =
|
||||
"$pull": {member_ids:user_id}
|
||||
Subscription.update searchOps, removeOperation, ->
|
||||
Subscription.update searchOps, removeOperation, (err)->
|
||||
if err?
|
||||
logger.err err:err, searchOps:searchOps, removeOperation:removeOperation, "error removing user from group"
|
||||
return callback(err)
|
||||
UserFeaturesUpdater.updateFeatures user_id, Settings.defaultPlanCode, callback
|
||||
|
||||
|
||||
_createNewSubscription: (adminUser_id, callback)->
|
||||
logger.log adminUser_id:adminUser_id, "creating new subscription"
|
||||
subscription = new Subscription(admin_id:adminUser_id)
|
||||
|
|
Loading…
Reference in a new issue