forked from External/greenlight
GRN-93: Fix for issue with excesive requests to LB (#447)
* Fix for issue with excesive requests to lb * Fixed issue with rspec on users not passing when run alone * Include dotenv in production
This commit is contained in:
parent
c07cfd0d93
commit
2b0301da38
4
Gemfile
4
Gemfile
|
@ -78,9 +78,9 @@ end
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||||
gem 'byebug', platform: :mri
|
gem 'byebug', platform: :mri
|
||||||
# Environment configuration.
|
|
||||||
gem 'dotenv-rails'
|
|
||||||
end
|
end
|
||||||
|
# Environment configuration.
|
||||||
|
gem 'dotenv-rails'
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
# Include Rspec and other testing utilities.
|
# Include Rspec and other testing utilities.
|
||||||
|
|
|
@ -111,7 +111,7 @@ class ApplicationController < ActionController::Base
|
||||||
@user_domain = if Rails.env.test? || !Rails.configuration.loadbalanced_configuration
|
@user_domain = if Rails.env.test? || !Rails.configuration.loadbalanced_configuration
|
||||||
"greenlight"
|
"greenlight"
|
||||||
else
|
else
|
||||||
parse_user_domain(request.env["SERVER_NAME"])
|
parse_user_domain(request.host)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
helper_method :set_user_domain
|
helper_method :set_user_domain
|
||||||
|
|
|
@ -84,7 +84,8 @@ module ApplicationHelper
|
||||||
begin
|
begin
|
||||||
provider_info = retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials')
|
provider_info = retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials')
|
||||||
provider_info['provider'] == 'greenlight'
|
provider_info['provider'] == 'greenlight'
|
||||||
rescue
|
rescue => ex
|
||||||
|
logger.info ex
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,7 +54,9 @@ module SessionsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_user_domain(hostname)
|
def parse_user_domain(hostname)
|
||||||
hostname.split('.').first
|
return hostname.split('.').first unless Rails.configuration.url_host
|
||||||
|
return '' unless hostname.include?(Rails.configuration.url_host)
|
||||||
|
hostname.chomp(Rails.configuration.url_host).chomp('.')
|
||||||
end
|
end
|
||||||
|
|
||||||
def omniauth_options(env)
|
def omniauth_options(env)
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
class UserMailer < ApplicationMailer
|
class UserMailer < ApplicationMailer
|
||||||
default from: Rails.configuration.email_sender
|
default from: Rails.configuration.smtp_sender
|
||||||
|
|
||||||
def verify_email(user, url)
|
def verify_email(user, url)
|
||||||
@user = user
|
@user = user
|
||||||
|
|
|
@ -185,6 +185,7 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def greenlight_account?
|
def greenlight_account?
|
||||||
|
return true unless provider # For testing cases when provider is set to null
|
||||||
return provider == "greenlight" unless Rails.configuration.loadbalanced_configuration
|
return provider == "greenlight" unless Rails.configuration.loadbalanced_configuration
|
||||||
# No need to retrive the provider info if the provider is whitelisted
|
# No need to retrive the provider info if the provider is whitelisted
|
||||||
return true if launcher_allow_user_signup_whitelisted?(provider)
|
return true if launcher_allow_user_signup_whitelisted?(provider)
|
||||||
|
|
|
@ -68,10 +68,13 @@ module Greenlight
|
||||||
# Fix endpoint format if required.
|
# Fix endpoint format if required.
|
||||||
config.loadbalancer_endpoint += "/" unless config.bigbluebutton_endpoint.ends_with?("/")
|
config.loadbalancer_endpoint += "/" unless config.bigbluebutton_endpoint.ends_with?("/")
|
||||||
config.loadbalancer_endpoint = config.loadbalancer_endpoint.chomp("api/")
|
config.loadbalancer_endpoint = config.loadbalancer_endpoint.chomp("api/")
|
||||||
|
|
||||||
|
# Configure which settings are available to user on room creation/edit after creation
|
||||||
|
config.url_host = ENV['URL_HOST'] || ''
|
||||||
end
|
end
|
||||||
|
|
||||||
# Specify the email address that all mail is sent from
|
# Specify the email address that all mail is sent from
|
||||||
config.email_sender = ENV['EMAIL_SENDER'].present? ? ENV['EMAIL_SENDER'] : "notifications@example.com"
|
config.smtp_sender = ENV['SMTP_SENDER'] || "notifications@example.com"
|
||||||
|
|
||||||
# Determine if GreenLight should enable email verification
|
# Determine if GreenLight should enable email verification
|
||||||
config.enable_email_verification = (ENV['ALLOW_MAIL_NOTIFICATIONS'] == "true")
|
config.enable_email_verification = (ENV['ALLOW_MAIL_NOTIFICATIONS'] == "true")
|
||||||
|
|
|
@ -31,7 +31,7 @@ module BbbApi
|
||||||
# Rereives info from the loadbalanced in regards to a Provider (or tenant).
|
# Rereives info from the loadbalanced in regards to a Provider (or tenant).
|
||||||
def retrieve_provider_info(provider, api = 'api', route = 'getUser')
|
def retrieve_provider_info(provider, api = 'api', route = 'getUser')
|
||||||
# Include Omniauth accounts under the Greenlight provider.
|
# Include Omniauth accounts under the Greenlight provider.
|
||||||
provider ||= 'greenlight'
|
raise "Provider not included." if !provider || provider.empty?
|
||||||
|
|
||||||
# Build the URI.
|
# Build the URI.
|
||||||
uri = encode_bbb_url(
|
uri = encode_bbb_url(
|
||||||
|
|
|
@ -103,7 +103,7 @@ SMTP_AUTH=
|
||||||
SMTP_STARTTLS_AUTO=
|
SMTP_STARTTLS_AUTO=
|
||||||
|
|
||||||
# Specify the email address that all mail is sent from
|
# Specify the email address that all mail is sent from
|
||||||
EMAIL_SENDER=
|
SMTP_SENDER=
|
||||||
|
|
||||||
# Prefix for the applications root URL.
|
# Prefix for the applications root URL.
|
||||||
# Useful for deploying the application to a subdirectory, which is highly recommended
|
# Useful for deploying the application to a subdirectory, which is highly recommended
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :user do
|
factory :user do
|
||||||
password = Faker::Internet.password(8)
|
password = Faker::Internet.password(8)
|
||||||
|
|
||||||
provider { %w(google twitter).sample }
|
provider { %w(google twitter).sample }
|
||||||
uid { rand(10**8) }
|
uid { rand(10**8) }
|
||||||
name { Faker::Name.first_name }
|
name { Faker::Name.first_name }
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
require 'bigbluebutton_api'
|
||||||
|
|
||||||
describe User, type: :model do
|
describe User, type: :model do
|
||||||
before do
|
before do
|
||||||
|
|
Loading…
Reference in New Issue