scinote-web/app/utilities/subdomain.rb
Nejc Bernot 495c648f41 Added subdomain based routing constraints
Non-wopi routes will only work with the subdomain set by the env variable USER_SUBDOMAIN (if it is set). Likewise, wopi routes will only work with the WOPI_SUBDOMAIN if it is set, but they also require the WOPI_ENABLED to be true.
2016-11-30 16:43:33 +01:00

23 lines
480 B
Ruby

class UserSubdomain
def self.matches?(request)
if ENV['USER_SUBDOMAIN']
return request.subdomain.present? && request.subdomain = ENV['USER_SUBDOMAIN']
else
return true
end
end
end
class WopiSubdomain
def self.matches?(request)
if ENV['WOPI_ENABLED'] == "true"
if ENV['WOPI_SUBDOMAIN']
return request.subdomain.present? && request.subdomain = ENV['WOPI_SUBDOMAIN']
else
return true
end
else
return false
end
end
end