2019-05-29 05:21:06 -04:00
|
|
|
const AuthenticationController = require('../Authentication/AuthenticationController')
|
|
|
|
const SubscriptionController = require('./SubscriptionController')
|
|
|
|
const SubscriptionGroupController = require('./SubscriptionGroupController')
|
|
|
|
const TeamInvitesController = require('./TeamInvitesController')
|
|
|
|
const RateLimiterMiddleware = require('../Security/RateLimiterMiddleware')
|
2021-07-07 05:38:56 -04:00
|
|
|
const Settings = require('@overleaf/settings')
|
2019-05-29 05:21:06 -04:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
apply(webRouter, privateApiRouter, publicApiRouter) {
|
|
|
|
if (!Settings.enableSubscriptions) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
webRouter.get('/user/subscription/plans', SubscriptionController.plansPage)
|
|
|
|
|
|
|
|
webRouter.get(
|
|
|
|
'/user/subscription',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionController.userSubscriptionPage
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.get(
|
|
|
|
'/user/subscription/new',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionController.paymentPage
|
|
|
|
)
|
|
|
|
|
2022-06-13 05:33:26 -04:00
|
|
|
webRouter.get(
|
2022-06-17 07:55:16 -04:00
|
|
|
'/user/subscription/choose-your-plan',
|
2022-06-13 05:33:26 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionController.interstitialPaymentPage
|
|
|
|
)
|
|
|
|
|
2019-05-29 05:21:06 -04:00
|
|
|
webRouter.get(
|
|
|
|
'/user/subscription/thank-you',
|
|
|
|
AuthenticationController.requireLogin(),
|
2021-05-26 08:26:59 -04:00
|
|
|
SubscriptionController.successfulSubscription
|
2019-05-29 05:21:06 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.get(
|
|
|
|
'/user/subscription/canceled',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionController.canceledSubscription
|
|
|
|
)
|
|
|
|
|
2021-12-14 08:26:07 -05:00
|
|
|
webRouter.get(
|
|
|
|
'/user/subscription/recurly/:pageType',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionController.redirectToHostedPage
|
|
|
|
)
|
|
|
|
|
2019-05-29 05:21:06 -04:00
|
|
|
webRouter.delete(
|
|
|
|
'/subscription/group/user',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionGroupController.removeSelfFromGroup
|
|
|
|
)
|
|
|
|
|
|
|
|
// Team invites
|
|
|
|
webRouter.get(
|
|
|
|
'/subscription/invites/:token/',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
TeamInvitesController.viewInvite
|
|
|
|
)
|
|
|
|
webRouter.put(
|
|
|
|
'/subscription/invites/:token/',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'team-invite',
|
|
|
|
maxRequests: 10,
|
2021-04-27 03:52:58 -04:00
|
|
|
timeInterval: 60,
|
2019-05-29 05:21:06 -04:00
|
|
|
}),
|
|
|
|
TeamInvitesController.acceptInvite
|
|
|
|
)
|
|
|
|
|
|
|
|
// recurly callback
|
|
|
|
publicApiRouter.post(
|
|
|
|
'/user/subscription/callback',
|
2021-06-08 09:03:39 -04:00
|
|
|
AuthenticationController.requireBasicAuth({
|
|
|
|
[Settings.apis.recurly.webhookUser]: Settings.apis.recurly.webhookPass,
|
|
|
|
}),
|
2019-05-29 05:21:06 -04:00
|
|
|
SubscriptionController.recurlyNotificationParser,
|
|
|
|
SubscriptionController.recurlyCallback
|
|
|
|
)
|
|
|
|
|
|
|
|
// user changes their account state
|
|
|
|
webRouter.post(
|
|
|
|
'/user/subscription/create',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionController.createSubscription
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/user/subscription/update',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionController.updateSubscription
|
|
|
|
)
|
2021-04-27 10:17:39 -04:00
|
|
|
webRouter.post(
|
|
|
|
'/user/subscription/cancel-pending',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionController.cancelPendingSubscriptionChange
|
|
|
|
)
|
2019-05-29 05:21:06 -04:00
|
|
|
webRouter.post(
|
|
|
|
'/user/subscription/cancel',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionController.cancelSubscription
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/user/subscription/reactivate',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionController.reactivateSubscription
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.post(
|
|
|
|
'/user/subscription/v1/cancel',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionController.cancelV1Subscription
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.put(
|
|
|
|
'/user/subscription/extend',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionController.extendTrial
|
|
|
|
)
|
|
|
|
|
|
|
|
webRouter.get(
|
|
|
|
'/user/subscription/upgrade-annual',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionController.renderUpgradeToAnnualPlanPage
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/user/subscription/upgrade-annual',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionController.processUpgradeToAnnualPlan
|
|
|
|
)
|
|
|
|
|
2020-02-20 11:08:30 -05:00
|
|
|
webRouter.post(
|
|
|
|
'/user/subscription/account/email',
|
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
SubscriptionController.updateAccountEmailAddress
|
|
|
|
)
|
2021-04-27 03:52:58 -04:00
|
|
|
},
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|