From a33b480c67f26bdc2413b98ef58dc897007eeae6 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Wed, 9 Mar 2016 11:17:03 +0000 Subject: [PATCH] added more logging to subscription group handler --- .../Subscription/SubscriptionGroupController.coffee | 7 ++++--- .../Subscription/SubscriptionGroupHandler.coffee | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/services/web/app/coffee/Features/Subscription/SubscriptionGroupController.coffee b/services/web/app/coffee/Features/Subscription/SubscriptionGroupController.coffee index 4f5d3cb3d0..269adb866f 100644 --- a/services/web/app/coffee/Features/Subscription/SubscriptionGroupController.coffee +++ b/services/web/app/coffee/Features/Subscription/SubscriptionGroupController.coffee @@ -90,11 +90,12 @@ module.exports = logger.log subscription_id:subscription_id, user_id:req?.session?.user?._id, email:email, "starting the completion of joining group" SubscriptionGroupHandler.processGroupVerification email, subscription_id, req.query?.token, (err)-> if err? and err == "token_not_found" - res.redirect "/user/subscription/#{subscription_id}/group/invited?expired=true" + return res.redirect "/user/subscription/#{subscription_id}/group/invited?expired=true" else if err? - res.sendStatus 500 + return res.sendStatus 500 else - res.redirect "/user/subscription/#{subscription_id}/group/successful-join" + logger.log subscription_id:subscription_id, email:email, "user successful completed join of group subscription" + return res.redirect "/user/subscription/#{subscription_id}/group/successful-join" renderSuccessfulJoinPage: (req, res)-> subscription_id = req.params.subscription_id diff --git a/services/web/app/coffee/Features/Subscription/SubscriptionGroupHandler.coffee b/services/web/app/coffee/Features/Subscription/SubscriptionGroupHandler.coffee index 4905203282..1f078f6674 100644 --- a/services/web/app/coffee/Features/Subscription/SubscriptionGroupHandler.coffee +++ b/services/web/app/coffee/Features/Subscription/SubscriptionGroupHandler.coffee @@ -14,9 +14,10 @@ NotificationsBuilder = require("../Notifications/NotificationsBuilder") module.exports = SubscriptionGroupHandler = addUserToGroup: (adminUserId, newEmail, callback)-> + logger.log adminUserId:adminUserId, newEmail:newEmail, "adding user to group" UserCreator.getUserOrCreateHoldingAccount newEmail, (err, user)-> if err? - logger.err err:err, "error creating user for holding account" + logger.err err:err, adminUserId:adminUserId, newEmail:newEmail, "error creating user for holding account" return callback(err) if !user? msg = "no user returned whenc reating holidng account or getting user" @@ -24,8 +25,10 @@ module.exports = SubscriptionGroupHandler = return callback(msg) LimitationsManager.hasGroupMembersLimitReached adminUserId, (err, limitReached, subscription)-> if err? + logger.err err:err, adminUserId:adminUserId, newEmail:newEmail, "error checking if limit reached for group plan" return callback(err) if limitReached + logger.err adminUserId:adminUserId, newEmail:newEmail, "group subscription limit reached not adding user to group" return callback(limitReached:limitReached) SubscriptionUpdater.addUserToGroup adminUserId, user._id, (err)-> if err? @@ -74,8 +77,8 @@ module.exports = SubscriptionGroupHandler = EmailHandler.sendEmail "completeJoinGroupAccount", opts, callback processGroupVerification: (userEmail, subscription_id, token, callback)-> + logger.log userEmail:userEmail, subscription_id:subscription_id, "processing group verification for user" OneTimeTokenHandler.getValueFromTokenAndExpire token, (err, token_subscription_id)-> - if err? or subscription_id != token_subscription_id logger.err userEmail:userEmail, token:token, "token value not found for processing group verification" return callback("token_not_found") @@ -84,7 +87,7 @@ module.exports = SubscriptionGroupHandler = logger.err err:err, subscription:subscription, userEmail:userEmail, subscription_id:subscription_id, "error getting subscription" return callback(err) if !subscription? - logger.warn subscription_id:subscription_id, "no subscription found" + logger.warn subscription_id:subscription_id, userEmail:userEmail, "no subscription found" return callback() SubscriptionGroupHandler.addUserToGroup subscription?.admin_id, userEmail, callback