overleaf/services/web/app/coffee/Features/Subscription/SubscriptionDomainHandler.coffee

34 lines
992 B
CoffeeScript
Raw Normal View History

2015-01-27 13:09:56 -05:00
async = require("async")
_ = require("underscore")
2015-01-27 13:09:56 -05:00
settings = require("settings-sharelatex")
module.exports = SubscriptionDomainHandler =
2015-01-27 13:09:56 -05:00
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/#{licence.subscription_id}/group/invited"
else
return undefined
2015-01-27 13:09:56 -05:00
_findDomainLicence: (email)->
licence = _.find settings.domainLicences, (licence)->
_.find licence.domains, (domain)->
2016-02-03 11:07:44 -05:00
regex = "[@\.]#{domain}"
return email.match(regex)
2015-01-27 13:09:56 -05:00
return licence
findDomainLicenceBySubscriptionId: (subscription_id)->
licence = _.find settings.domainLicences, (licence)->
licence?.subscription_id == subscription_id
return licence