Move v2 plans redirect to router

This commit is contained in:
Jessica Lawshe 2018-08-27 10:23:11 -05:00
parent ec710d0b1e
commit bac90c0976
2 changed files with 26 additions and 27 deletions

View file

@ -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) ->

View file

@ -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