From bac90c09760b9c4be3d893772bdd77e58e25db02 Mon Sep 17 00:00:00 2001 From: Jessica Lawshe Date: Mon, 27 Aug 2018 10:23:11 -0500 Subject: [PATCH] Move v2 plans redirect to router --- .../SubscriptionController.coffee | 47 ++++++++++--------- .../Subscription/SubscriptionRouter.coffee | 6 +-- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee b/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee index cf1bf59ebd..2b7ca06ca8 100644 --- a/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee +++ b/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee @@ -15,30 +15,33 @@ planFeatures = require './planFeatures' module.exports = SubscriptionController = plansPage: (req, res, next) -> - plans = SubscriptionViewModelBuilder.buildViewModel() - viewName = "subscriptions/plans" - if req.query.v? - viewName = "#{viewName}_#{req.query.v}" - logger.log viewName:viewName, "showing plans page" - currentUser = null + if Settings.overleaf? && !req.query.plns + res.redirect "#{Settings.overleaf.host}/plans" + else + plans = SubscriptionViewModelBuilder.buildViewModel() + viewName = "subscriptions/plans" + if req.query.v? + viewName = "#{viewName}_#{req.query.v}" + logger.log viewName:viewName, "showing plans page" + currentUser = null - GeoIpLookup.getCurrencyCode req.query?.ip || req.ip, (err, recomendedCurrency)-> - return next(err) if err? - render = () -> - res.render viewName, - title: "plans_and_pricing" - plans: plans - gaExperiments: Settings.gaExperiments.plansPage - recomendedCurrency:recomendedCurrency - planFeatures: planFeatures - user_id = AuthenticationController.getLoggedInUserId(req) - if user_id? - UserGetter.getUser user_id, {signUpDate: 1}, (err, user) -> - return next(err) if err? - currentUser = user + GeoIpLookup.getCurrencyCode req.query?.ip || req.ip, (err, recomendedCurrency)-> + return next(err) if err? + render = () -> + res.render viewName, + title: "plans_and_pricing" + plans: plans + gaExperiments: Settings.gaExperiments.plansPage + recomendedCurrency:recomendedCurrency + planFeatures: planFeatures + user_id = AuthenticationController.getLoggedInUserId(req) + if user_id? + UserGetter.getUser user_id, {signUpDate: 1}, (err, user) -> + return next(err) if err? + currentUser = user + render() + else render() - else - render() #get to show the recurly.js page paymentPage: (req, res, next) -> diff --git a/services/web/app/coffee/Features/Subscription/SubscriptionRouter.coffee b/services/web/app/coffee/Features/Subscription/SubscriptionRouter.coffee index 9e9cc702f5..8950e3c5bd 100644 --- a/services/web/app/coffee/Features/Subscription/SubscriptionRouter.coffee +++ b/services/web/app/coffee/Features/Subscription/SubscriptionRouter.coffee @@ -9,11 +9,7 @@ module.exports = apply: (webRouter, privateApiRouter, publicApiRouter) -> return unless Settings.enableSubscriptions - if Settings.overleaf? - webRouter.get '/user/subscription/plans', (req, res) -> - res.redirect "#{Settings.overleaf.host}/plans" - else - webRouter.get '/user/subscription/plans', SubscriptionController.plansPage + webRouter.get '/user/subscription/plans', SubscriptionController.plansPage webRouter.get '/user/subscription', AuthenticationController.requireLogin(), SubscriptionController.userSubscriptionPage