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 = module.exports = SubscriptionController =
plansPage: (req, res, next) -> plansPage: (req, res, next) ->
plans = SubscriptionViewModelBuilder.buildViewModel() if Settings.overleaf? && !req.query.plns
viewName = "subscriptions/plans" res.redirect "#{Settings.overleaf.host}/plans"
if req.query.v? else
viewName = "#{viewName}_#{req.query.v}" plans = SubscriptionViewModelBuilder.buildViewModel()
logger.log viewName:viewName, "showing plans page" viewName = "subscriptions/plans"
currentUser = null 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)-> GeoIpLookup.getCurrencyCode req.query?.ip || req.ip, (err, recomendedCurrency)->
return next(err) if err? return next(err) if err?
render = () -> render = () ->
res.render viewName, res.render viewName,
title: "plans_and_pricing" title: "plans_and_pricing"
plans: plans plans: plans
gaExperiments: Settings.gaExperiments.plansPage gaExperiments: Settings.gaExperiments.plansPage
recomendedCurrency:recomendedCurrency recomendedCurrency:recomendedCurrency
planFeatures: planFeatures planFeatures: planFeatures
user_id = AuthenticationController.getLoggedInUserId(req) user_id = AuthenticationController.getLoggedInUserId(req)
if user_id? if user_id?
UserGetter.getUser user_id, {signUpDate: 1}, (err, user) -> UserGetter.getUser user_id, {signUpDate: 1}, (err, user) ->
return next(err) if err? return next(err) if err?
currentUser = user currentUser = user
render()
else
render() render()
else
render()
#get to show the recurly.js page #get to show the recurly.js page
paymentPage: (req, res, next) -> paymentPage: (req, res, next) ->

View file

@ -9,11 +9,7 @@ module.exports =
apply: (webRouter, privateApiRouter, publicApiRouter) -> apply: (webRouter, privateApiRouter, publicApiRouter) ->
return unless Settings.enableSubscriptions return unless Settings.enableSubscriptions
if Settings.overleaf? webRouter.get '/user/subscription/plans', SubscriptionController.plansPage
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', AuthenticationController.requireLogin(), SubscriptionController.userSubscriptionPage webRouter.get '/user/subscription', AuthenticationController.requireLogin(), SubscriptionController.userSubscriptionPage