diff --git a/Gemfile b/Gemfile
index 80b99f7a..caf80440 100644
--- a/Gemfile
+++ b/Gemfile
@@ -78,9 +78,9 @@ end
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
- # Environment configuration.
- gem 'dotenv-rails'
end
+# Environment configuration.
+gem 'dotenv-rails'
group :test do
# Include Rspec and other testing utilities.
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index cd40cd46..e8dfd653 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -111,7 +111,7 @@ class ApplicationController < ActionController::Base
@user_domain = if Rails.env.test? || !Rails.configuration.loadbalanced_configuration
"greenlight"
else
- parse_user_domain(request.env["SERVER_NAME"])
+ parse_user_domain(request.host)
end
end
helper_method :set_user_domain
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 1cbbdf72..bf5c591e 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -84,7 +84,8 @@ module ApplicationHelper
begin
provider_info = retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials')
provider_info['provider'] == 'greenlight'
- rescue
+ rescue => ex
+ logger.info ex
false
end
end
diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb
index f0d63d62..ba2d26a7 100644
--- a/app/helpers/sessions_helper.rb
+++ b/app/helpers/sessions_helper.rb
@@ -54,7 +54,9 @@ module SessionsHelper
end
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
def omniauth_options(env)
diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb
index abef46de..2ca2f404 100644
--- a/app/mailers/user_mailer.rb
+++ b/app/mailers/user_mailer.rb
@@ -17,7 +17,7 @@
# with BigBlueButton; if not, see .
class UserMailer < ApplicationMailer
- default from: Rails.configuration.email_sender
+ default from: Rails.configuration.smtp_sender
def verify_email(user, url)
@user = user
diff --git a/app/models/user.rb b/app/models/user.rb
index 342f216d..4a4611bf 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -185,6 +185,7 @@ class User < ApplicationRecord
end
def greenlight_account?
+ return true unless provider # For testing cases when provider is set to null
return provider == "greenlight" unless Rails.configuration.loadbalanced_configuration
# No need to retrive the provider info if the provider is whitelisted
return true if launcher_allow_user_signup_whitelisted?(provider)
diff --git a/config/application.rb b/config/application.rb
index f65375a8..6bd99b67 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -68,10 +68,13 @@ module Greenlight
# Fix endpoint format if required.
config.loadbalancer_endpoint += "/" unless config.bigbluebutton_endpoint.ends_with?("/")
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
# 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
config.enable_email_verification = (ENV['ALLOW_MAIL_NOTIFICATIONS'] == "true")
diff --git a/lib/bbb_api.rb b/lib/bbb_api.rb
index ef16d256..09c601ad 100644
--- a/lib/bbb_api.rb
+++ b/lib/bbb_api.rb
@@ -31,7 +31,7 @@ module BbbApi
# Rereives info from the loadbalanced in regards to a Provider (or tenant).
def retrieve_provider_info(provider, api = 'api', route = 'getUser')
# Include Omniauth accounts under the Greenlight provider.
- provider ||= 'greenlight'
+ raise "Provider not included." if !provider || provider.empty?
# Build the URI.
uri = encode_bbb_url(
diff --git a/sample.env b/sample.env
index 97baf5db..2e843e3d 100644
--- a/sample.env
+++ b/sample.env
@@ -103,7 +103,7 @@ SMTP_AUTH=
SMTP_STARTTLS_AUTO=
# Specify the email address that all mail is sent from
-EMAIL_SENDER=
+SMTP_SENDER=
# Prefix for the applications root URL.
# Useful for deploying the application to a subdirectory, which is highly recommended
diff --git a/spec/factories.rb b/spec/factories.rb
index de8a3975..0b3aa58a 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -19,7 +19,6 @@
FactoryBot.define do
factory :user do
password = Faker::Internet.password(8)
-
provider { %w(google twitter).sample }
uid { rand(10**8) }
name { Faker::Name.first_name }
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 72af5432..e94086b8 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -17,6 +17,7 @@
# with BigBlueButton; if not, see .
require "rails_helper"
+require 'bigbluebutton_api'
describe User, type: :model do
before do