overleaf/services/web/app/coffee/Features/Subscription/SubscriptionDomainHandler.coffee
2018-05-31 16:15:47 +01:00

33 lines
963 B
CoffeeScript

async = require("async")
_ = require("underscore")
settings = require("settings-sharelatex")
module.exports = SubscriptionDomainHandler =
getLicenceUserCanJoin: (user)->
licence = SubscriptionDomainHandler._findDomainLicence(user.email)
return licence
rejectInvitationToGroup: (user, subscription, callback)->
removeUserFromGroup(subscription.admin_id, user._id, callback)
getDomainLicencePage: (user)->
licence = SubscriptionDomainHandler._findDomainLicence(user.email)
if licence?.verifyEmail
return "/user/subscription/domain/join"
else
return undefined
_findDomainLicence: (email)->
licence = _.find settings.domainLicences, (licence)->
_.find licence.domains, (domain)->
regex = "[@\.]#{domain}"
return email.match(regex)
return licence
findDomainLicenceBySubscriptionId: (subscription_id)->
licence = _.find settings.domainLicences, (licence)->
licence?.subscription_id == subscription_id
return licence