mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
if its a custom account redirect to /user/subscription/custom_account
This commit is contained in:
parent
c7a3cb87c2
commit
3ba3a91043
3 changed files with 18 additions and 4 deletions
|
@ -30,12 +30,12 @@ module.exports =
|
|||
callback null, true
|
||||
|
||||
userHasSubscriptionOrIsGroupMember: (user, callback = (err, hasSubscriptionOrIsMember)->) ->
|
||||
@userHasSubscription user, (err, hasSubscription)=>
|
||||
@userHasSubscription user, (err, hasSubscription, subscription)=>
|
||||
return callback(err) if err?
|
||||
@userIsMemberOfGroupSubscription user, (err, isMember)=>
|
||||
return callback(err) if err?
|
||||
logger.log user_id:user._id, isMember:isMember, hasSubscription:hasSubscription, "checking if user has subscription or is group member"
|
||||
callback err, isMember or hasSubscription
|
||||
callback err, isMember or hasSubscription, subscription
|
||||
|
||||
userHasSubscription: (user, callback = (err, hasSubscription, subscription)->) ->
|
||||
logger.log user_id:user._id, "checking if user has subscription"
|
||||
|
|
|
@ -69,8 +69,11 @@ module.exports = SubscriptionController =
|
|||
userSubscriptionPage: (req, res, next) ->
|
||||
SecurityManager.getCurrentUser req, (error, user) =>
|
||||
return next(error) if error?
|
||||
LimitationsManager.userHasSubscriptionOrIsGroupMember user, (err, hasSubOrIsGroupMember)->
|
||||
if !hasSubOrIsGroupMember
|
||||
LimitationsManager.userHasSubscriptionOrIsGroupMember user, (err, hasSubOrIsGroupMember, subscription)->
|
||||
if subscription?.customAccount
|
||||
logger.log user: user, "redirecting to plans"
|
||||
res.redirect "/user/subscription/custom_account"
|
||||
else if !hasSubOrIsGroupMember
|
||||
logger.log user: user, "redirecting to plans"
|
||||
res.redirect "/user/subscription/plans"
|
||||
else
|
||||
|
|
|
@ -184,6 +184,17 @@ describe "SubscriptionController sanboxed", ->
|
|||
it "should set the correct subscription details", ->
|
||||
@res.renderedVariables.subscription.should.deep.equal @activeRecurlySubscription
|
||||
|
||||
|
||||
describe "when its a custom subscription which is non recurly", ->
|
||||
beforeEach ()->
|
||||
@LimitationsManager.userHasSubscriptionOrIsGroupMember.callsArgWith(1, null, true, {customAccount:true})
|
||||
@SubscriptionController.userSubscriptionPage @req, @res
|
||||
|
||||
it "should redirect to /user/subscription/custom_account", ->
|
||||
@res.redirectedTo.should.equal("/user/subscription/custom_account")
|
||||
|
||||
|
||||
|
||||
describe "createSubscription", ->
|
||||
beforeEach (done)->
|
||||
@res =
|
||||
|
|
Loading…
Reference in a new issue