mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-27 07:13:44 +00:00
Merge pull request #2702 from overleaf/ta-subscription-links
Fix Language Change Links GitOrigin-RevId: e47f59dfd53102d4569c3ffeb950d3259c65215b
This commit is contained in:
parent
78561cb393
commit
344b2b2395
4 changed files with 24 additions and 8 deletions
|
@ -81,6 +81,13 @@ module.exports = SubscriptionController = {
|
|||
paymentPage(req, res, next) {
|
||||
const user = AuthenticationController.getSessionUser(req)
|
||||
const plan = PlansLocator.findLocalPlanInSettings(req.query.planCode)
|
||||
if (!plan) {
|
||||
return next(
|
||||
new HttpErrors.UnprocessableEntityError({
|
||||
info: { public: { message: 'Plan not found' } }
|
||||
})
|
||||
)
|
||||
}
|
||||
return LimitationsManager.userHasV1OrV2Subscription(user, function(
|
||||
err,
|
||||
hasSubscription
|
||||
|
@ -88,7 +95,7 @@ module.exports = SubscriptionController = {
|
|||
if (err != null) {
|
||||
return next(err)
|
||||
}
|
||||
if (hasSubscription || plan == null) {
|
||||
if (hasSubscription) {
|
||||
return res.redirect('/user/subscription?hasSubscription=true')
|
||||
} else {
|
||||
// LimitationsManager.userHasV2Subscription only checks Mongo. Double check with
|
||||
|
|
|
@ -196,7 +196,9 @@ module.exports = function(webRouter, privateApiRouter, publicApiRouter) {
|
|||
}
|
||||
// Don't include the query string parameters, otherwise Google
|
||||
// treats ?nocdn=true as the canonical version
|
||||
res.locals.currentUrl = Url.parse(req.originalUrl).pathname
|
||||
const parsedOriginalUrl = Url.parse(req.originalUrl)
|
||||
res.locals.currentUrl = parsedOriginalUrl.pathname
|
||||
res.locals.currentUrlWithQueryParams = parsedOriginalUrl.path
|
||||
res.locals.capitalize = function(string) {
|
||||
if (string.length === 0) {
|
||||
return ''
|
||||
|
|
|
@ -23,7 +23,7 @@ footer.site-footer
|
|||
each subdomainDetails, subdomain in settings.i18n.subdomainLang
|
||||
if !subdomainDetails.hide
|
||||
li.lngOption
|
||||
a.menu-indent(href=subdomainDetails.url+currentUrl)
|
||||
a.menu-indent(href=subdomainDetails.url+currentUrlWithQueryParams)
|
||||
figure(class="sprite-icon sprite-icon-lang sprite-icon-"+subdomainDetails.lngCode alt=translate(subdomainDetails.lngCode))
|
||||
| #{translate(subdomainDetails.lngCode)}
|
||||
//- img(src="/img/flags/24/.png")
|
||||
|
|
|
@ -225,6 +225,7 @@ describe('SubscriptionController', function() {
|
|||
|
||||
describe('with a user with subscription', function() {
|
||||
it('should redirect to the subscription dashboard', function(done) {
|
||||
this.PlansLocator.findLocalPlanInSettings.returns({})
|
||||
this.LimitationsManager.userHasV1OrV2Subscription.callsArgWith(
|
||||
1,
|
||||
null,
|
||||
|
@ -239,18 +240,23 @@ describe('SubscriptionController', function() {
|
|||
})
|
||||
|
||||
describe('with an invalid plan code', function() {
|
||||
it('should redirect to the subscription dashboard', function(done) {
|
||||
it('should return 422 error', function(done) {
|
||||
this.LimitationsManager.userHasV1OrV2Subscription.callsArgWith(
|
||||
1,
|
||||
null,
|
||||
false
|
||||
)
|
||||
this.PlansLocator.findLocalPlanInSettings.returns(null)
|
||||
this.res.redirect = url => {
|
||||
url.should.equal('/user/subscription?hasSubscription=true')
|
||||
return done()
|
||||
this.next = error => {
|
||||
expect(error).to.exist
|
||||
expect(error.statusCode).to.equal(422)
|
||||
done()
|
||||
}
|
||||
return this.SubscriptionController.paymentPage(this.req, this.res)
|
||||
return this.SubscriptionController.paymentPage(
|
||||
this.req,
|
||||
this.res,
|
||||
this.next
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -295,6 +301,7 @@ describe('SubscriptionController', function() {
|
|||
|
||||
describe('with a recurly subscription already', function() {
|
||||
it('should redirect to the subscription dashboard', function(done) {
|
||||
this.PlansLocator.findLocalPlanInSettings.returns({})
|
||||
this.LimitationsManager.userHasV1OrV2Subscription.callsArgWith(
|
||||
1,
|
||||
null,
|
||||
|
|
Loading…
Reference in a new issue