mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
47 lines
1.5 KiB
CoffeeScript
47 lines
1.5 KiB
CoffeeScript
SubscriptionGroupHandler = require("./SubscriptionGroupHandler")
|
|
logger = require("logger-sharelatex")
|
|
SubscriptionLocator = require("./SubscriptionLocator")
|
|
ErrorsController = require("../Errors/ErrorController")
|
|
SubscriptionDomainHandler = require("./SubscriptionDomainHandler")
|
|
AuthenticationController = require('../Authentication/AuthenticationController')
|
|
TeamInvitesHandler = require('./TeamInvitesHandler')
|
|
|
|
async = require("async")
|
|
|
|
module.exports =
|
|
join: (req, res)->
|
|
user = AuthenticationController.getSessionUser(req)
|
|
licence = SubscriptionDomainHandler.getLicenceUserCanJoin(user)
|
|
|
|
if !licence?
|
|
return ErrorsController.notFound(req, res)
|
|
|
|
jobs =
|
|
partOfGroup: (cb)->
|
|
SubscriptionGroupHandler.isUserPartOfGroup user.id, licence.group_subscription_id, cb
|
|
subscription: (cb)->
|
|
SubscriptionLocator.getUsersSubscription user.id, cb
|
|
|
|
async.series jobs, (err, results)->
|
|
{ partOfGroup, subscription } = results
|
|
if partOfGroup
|
|
return res.redirect("/user/subscription/custom_account")
|
|
else
|
|
res.render "subscriptions/domain/join",
|
|
title: "Group Invitation"
|
|
group_subscription_id: licence.group_subscription_id
|
|
licenceName: licence.name
|
|
has_personal_subscription: subscription?
|
|
|
|
createInvite: (req, res)->
|
|
user = AuthenticationController.getSessionUser(req)
|
|
licence = SubscriptionDomainHandler.getLicenceUserCanJoin(user)
|
|
|
|
if !licence?
|
|
return ErrorsController.notFound(req, res)
|
|
|
|
TeamInvitesHandler.createDomainInvite user, licence, (err) ->
|
|
if err?
|
|
res.sendStatus 500
|
|
else
|
|
res.sendStatus 200
|