diff --git a/Gemfile b/Gemfile index 9c89ebf4..2e77d0e3 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,7 @@ gem 'coffee-rails', '~> 4.2' gem 'mini_racer', platforms: :ruby # Use jquery as the JavaScript library -gem 'jquery-rails' +gem 'jquery-rails', '~> 4.3.3' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' @@ -44,9 +44,10 @@ gem 'bcrypt', '~> 3.1.7' gem 'omniauth' gem 'omniauth-twitter' gem 'omniauth-google-oauth2' -gem 'omniauth-microsoft-office365', '~> 0.0.7' -gem 'omniauth-ldap' -gem 'omniauth-bn-launcher', '~> 0.1.0' +gem 'omniauth-bn-office365', git: 'https://github.com/blindsidenetworks/omniauth-bn-office365.git', tag: '0.1.0' +gem 'omniauth-bn-launcher', git: 'https://github.com/blindsidenetworks/omniauth-bn-launcher.git', tag: '0.1.1' +gem 'bn-ldap-authentication', git: 'https://github.com/blindsidenetworks/bn-ldap-authentication.git' +gem 'net-ldap' # BigBlueButton API wrapper. gem 'bigbluebutton-api-ruby' @@ -121,3 +122,5 @@ gem 'random_password' # Adds helpers for the Google reCAPTCHA API gem "recaptcha" + +gem 'i18n-language-mapping', '~> 0.1.0' diff --git a/Gemfile.lock b/Gemfile.lock index 322fc1cf..9bc6b0b0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,28 @@ +GIT + remote: https://github.com/blindsidenetworks/bn-ldap-authentication.git + revision: 538132e0df70dbe470120f7bc7a93968c522031f + specs: + bn-ldap-authentication (1.0.0) + net-ldap + +GIT + remote: https://github.com/blindsidenetworks/omniauth-bn-launcher.git + revision: 025785046c3d532ed2252ef4762469c8d08d4839 + tag: 0.1.1 + specs: + omniauth-bn-launcher (0.1.1) + omniauth (~> 1.3, >= 1.3.2) + omniauth-oauth2 (= 1.5.0) + +GIT + remote: https://github.com/blindsidenetworks/omniauth-bn-office365.git + revision: d6640b37b5df50b5ed80e1271518bfb5dfb2a966 + tag: 0.1.0 + specs: + omniauth-bn-office365 (1.0.0) + omniauth (>= 1.3.2) + omniauth-oauth2 (>= 1.5.0) + GEM remote: https://rubygems.org/ specs: @@ -101,6 +126,7 @@ GEM http_accept_language (2.1.1) i18n (1.6.0) concurrent-ruby (~> 1.0) + i18n-language-mapping (0.1.0) jaro_winkler (1.5.2) jbuilder (2.9.1) activesupport (>= 4.2.0) @@ -142,21 +168,10 @@ GEM omniauth (1.9.0) hashie (>= 3.4.6, < 3.7.0) rack (>= 1.6.2, < 3) - omniauth-bn-launcher (0.1.0) - omniauth (~> 1.3, >= 1.3.2) - omniauth-oauth2 (= 1.5.0) omniauth-google-oauth2 (0.6.1) jwt (>= 2.0) omniauth (>= 1.1.1) omniauth-oauth2 (>= 1.5) - omniauth-ldap (1.0.5) - net-ldap (~> 0.12) - omniauth (~> 1.0) - pyu-ruby-sasl (~> 0.0.3.2) - rubyntlm (~> 0.3.4) - omniauth-microsoft-office365 (0.0.7) - omniauth - omniauth-oauth2 omniauth-oauth (1.1.0) oauth omniauth (~> 1.0) @@ -174,7 +189,6 @@ GEM popper_js (1.14.5) public_suffix (3.0.3) puma (3.12.1) - pyu-ruby-sasl (0.0.3.3) rack (2.0.7) rack-test (0.6.3) rack (>= 1.0) @@ -243,7 +257,6 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 1.7) ruby-progressbar (1.10.0) - rubyntlm (0.3.4) safe_yaml (1.0.5) sass (3.7.4) sass-listen (~> 4.0.0) @@ -323,6 +336,7 @@ DEPENDENCIES action-cable-testing bcrypt (~> 3.1.7) bigbluebutton-api-ruby + bn-ldap-authentication! bootstrap (~> 4.3.1) byebug cancancan (~> 2.0) @@ -333,15 +347,16 @@ DEPENDENCIES faker health_check http_accept_language + i18n-language-mapping (~> 0.1.0) jbuilder (~> 2.5) - jquery-rails + jquery-rails (~> 4.3.3) listen (~> 3.0.5) mini_racer + net-ldap omniauth - omniauth-bn-launcher (~> 0.1.0) + omniauth-bn-launcher! + omniauth-bn-office365! omniauth-google-oauth2 - omniauth-ldap - omniauth-microsoft-office365 (~> 0.0.7) omniauth-twitter pagy pg (~> 0.18) diff --git a/README.md b/README.md index 16fa6b1d..8a5ce130 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,9 @@ !Status](https://coveralls.io/repos/github/bigbluebutton/greenlight/badge.svg?branch=master) ![Docker Pulls](https://img.shields.io/docker/pulls/bigbluebutton/greenlight.svg) -> Greenlight is currently on version 2.0. If you are still running Greenlight 1.0 we suggest [upgrading to 2.0](http://docs.bigbluebutton.org/greenlight/gl-install.html#upgrading-from-greenlight-10). - Greenlight is a simple front-end interface for your BigBlueButton server. At it's heart, Greenlight provides a minimalistic web-based application that allows users to: - * Signup/Login with Twitter, Google, or through the application itself. + * Signup/Login with Google, Office365, or through the application itself. * Manage your account settings and user preferences. * Create and manage your own personal rooms ([BigBlueButton](https://github.com/bigbluebutton/bigbluebutton) sessions). * Invite others to your room using a simple URL. diff --git a/app/assets/images/ldap-logo.png b/app/assets/images/ldap-logo.png new file mode 100644 index 00000000..f11320ef Binary files /dev/null and b/app/assets/images/ldap-logo.png differ diff --git a/app/assets/javascripts/admins.js b/app/assets/javascripts/admins.js index cd29fd8e..55fa3a43 100644 --- a/app/assets/javascripts/admins.js +++ b/app/assets/javascripts/admins.js @@ -45,45 +45,8 @@ $(document).on('turbolinks:load', function(){ }) /* COLOR SELECTORS */ - - $('#colorinput-regular').ColorPicker({ - onBeforeShow: function () { - var colour = rgb2hex($("#colorinput-regular").css("background-color")) - $(this).ColorPickerSetColor(colour); - }, - onSubmit: function(_hsb, hex) { - $.post($("#coloring-path-regular").val(), {color: '#' + hex}).done(function() { - location.reload() - }); - }, - }); - - $('#colorinput-lighten').ColorPicker({ - onBeforeShow: function () { - var colour = rgb2hex($("#colorinput-lighten").css("background-color")) - - $(this).ColorPickerSetColor(colour); - }, - onSubmit: function(_hsb, hex) { - $.post($("#coloring-path-lighten").val(), {color: '#' + hex}).done(function() { - location.reload() - }); - }, - }); - - $('#colorinput-darken').ColorPicker({ - onBeforeShow: function () { - var colour = rgb2hex($("#colorinput-darken").css("background-color")) - - $(this).ColorPickerSetColor(colour); - }, - onSubmit: function(_hsb, hex) { - $.post($("#coloring-path-darken").val(), {color: '#' + hex}).done(function() { - location.reload() - }); - }, - }); + loadColourSelectors() } // Only run on the admins edit user page. @@ -119,11 +82,82 @@ function filterRole(role) { window.location.replace(url); } -function rgb2hex(rgb) { - rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); - function hex(x) { - return ("0" + parseInt(x).toString(16)).slice(-2); - } - return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]); -} +function loadColourSelectors() { + const pickrRegular = new Pickr({ + el: '#colorinput-regular', + theme: 'monolith', + useAsButton: true, + lockOpacity: true, + defaultRepresentation: 'HEX', + closeWithKey: 'Enter', + default: $("#colorinput-regular").css("background-color"), + components: { + palette: true, + preview: true, + hue: true, + interaction: { + input: true, + save: true, + }, + }, + }); + + const pickrLighten = new Pickr({ + el: '#colorinput-lighten', + theme: 'monolith', + useAsButton: true, + lockOpacity: true, + defaultRepresentation: 'HEX', + closeWithKey: 'Enter', + default: $("#colorinput-lighten").css("background-color"), + + components: { + palette: true, + preview: true, + hue: true, + interaction: { + input: true, + save: true, + }, + }, + }); + + const pickrDarken = new Pickr({ + el: '#colorinput-darken', + theme: 'monolith', + useAsButton: true, + lockOpacity: true, + defaultRepresentation: 'HEX', + closeWithKey: 'Enter', + default: $("#colorinput-darken").css("background-color"), + + components: { + palette: true, + preview: true, + hue: true, + interaction: { + input: true, + save: true, + }, + }, + }); + + pickrRegular.on("save", (color, instance) => { + $.post($("#coloring-path-regular").val(), {color: color.toHEXA().toString()}).done(function() { + location.reload() + }); + }) + + pickrLighten.on("save", (color, instance) => { + $.post($("#coloring-path-lighten").val(), {color: color.toHEXA().toString()}).done(function() { + location.reload() + }); + }) + + pickrDarken.on("save", (color, instance) => { + $.post($("#coloring-path-darken").val(), {color: color.toHEXA().toString()}).done(function() { + location.reload() + }); + }) +} \ No newline at end of file diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 1bec0ad4..9e2fd706 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -31,5 +31,4 @@ //= require tabler //= require tabler.plugins //= require jquery_ujs -//= require colorpicker //= require_tree . diff --git a/app/assets/stylesheets/admins.scss b/app/assets/stylesheets/admins.scss index 56dbb86f..ee882a5d 100644 --- a/app/assets/stylesheets/admins.scss +++ b/app/assets/stylesheets/admins.scss @@ -18,6 +18,10 @@ .user-role { color: white !important; } + + .user-email { + max-width: 250px; + } } #clear-search { @@ -41,4 +45,13 @@ .authentication-required{ padding-top: 2px; +} + +#site_settings { + .colorinput-color { + text-align: center; + padding-top: 4px; + height: 2rem; + width: 2rem; + } } \ No newline at end of file diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index f3fdace1..d675a905 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -33,7 +33,6 @@ @import "tabler/variables"; @import "bootstrap"; @import "tabler-custom"; -@import "colorpicker"; @import "utilities/variables"; @import "admins"; diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index dcd6dacd..4271ade6 100755 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -123,7 +123,7 @@ } } -.customBtn-microsoft_office365 { +.customBtn-office365 { @extend .customBtn; background: #f65314; @@ -145,6 +145,17 @@ } } +.customBtn-ldap { + @extend .customBtn; + background: #d61515; + + .customBtn-image { + background: #ffffff image-url("ldap-logo.png") no-repeat left top; + background-size: 18px 18px; + padding:10px 10px 10px 10px; + } +} + .signin-button { font-size: 16px; } diff --git a/app/controllers/admins_controller.rb b/app/controllers/admins_controller.rb index 8f87171e..00ab91bc 100644 --- a/app/controllers/admins_controller.rb +++ b/app/controllers/admins_controller.rb @@ -23,7 +23,7 @@ class AdminsController < ApplicationController manage_users = [:edit_user, :promote, :demote, :ban_user, :unban_user, :approve] site_settings = [:branding, :coloring, :coloring_lighten, :coloring_darken, - :registration_method, :room_authentication] + :registration_method, :room_authentication, :room_limit] authorize_resource class: false before_action :find_user, only: manage_users @@ -153,6 +153,12 @@ class AdminsController < ApplicationController end end + # POST /admins/room_limit + def room_limit + @settings.update_value("Room Limit", params[:limit]) + redirect_to admins_path, flash: { success: I18n.t("administrator.flash.settings") } + end + private def find_user diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 95bb979b..70df16a3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -131,10 +131,25 @@ class ApplicationController < ActionController::Base end def set_user_domain - @user_domain = if Rails.env.test? || !Rails.configuration.loadbalanced_configuration - "greenlight" + if Rails.env.test? || !Rails.configuration.loadbalanced_configuration + @user_domain = "greenlight" else - parse_user_domain(request.host) + @user_domain = parse_user_domain(request.host) + + # Checks to see if the user exists + begin + retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials') + rescue => e + if e.message.eql? "No user with that id exists" + render "errors/not_found", locals: { message: I18n.t("errors.not_found.user_not_found.message"), + help: I18n.t("errors.not_found.user_not_found.help") } + elsif e.message.eql? "Provider not included." + render "errors/not_found", locals: { message: I18n.t("errors.not_found.user_missing.message"), + help: I18n.t("errors.not_found.user_missing.help") } + else + render "errors/internal_error" + end + end end end helper_method :set_user_domain diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index 5c388a4e..e9131af4 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -21,10 +21,6 @@ class ErrorsController < ApplicationController render status: 404, formats: :html end - def unprocessable - render status: 422, formats: :html - end - def internal_error render status: 500, formats: :html end diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb index b96166da..fde621b1 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/rooms_controller.rb @@ -33,6 +33,8 @@ class RoomsController < ApplicationController def create redirect_to(root_path) && return unless current_user + return redirect_to current_user.main_room, flash: { alert: I18n.t("room.room_limit") } if room_limit_exceeded + @room = Room.new(name: room_params[:name]) @room.owner = current_user @room.room_settings = create_room_settings_string(room_params[:mute_on_join], room_params[:client]) @@ -279,4 +281,14 @@ class RoomsController < ApplicationController Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Authentication") == "true" && current_user.nil? end + + def room_limit_exceeded + limit = Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Limit").to_i + + # Does not apply to admin + # 15+ option is used as unlimited + return false if current_user&.has_role?(:admin) || limit == 15 + + current_user.rooms.count >= limit + end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 4f6abdd0..f4de6416 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -19,6 +19,7 @@ class SessionsController < ApplicationController include Registrar include Emailer + include LdapAuthenticator skip_before_action :verify_authenticity_token, only: [:omniauth, :fail] @@ -47,33 +48,9 @@ class SessionsController < ApplicationController # GET/POST /auth/:provider/callback def omniauth - begin - @auth = request.env['omniauth.auth'] - @user_exists = check_user_exists + @auth = request.env['omniauth.auth'] - # If using invitation registration method, make sure user is invited - return redirect_to root_path, flash: { alert: I18n.t("registration.invite.no_invite") } unless passes_invite_reqs - - user = User.from_omniauth(@auth) - - # Add pending role if approval method and is a new user - if approval_registration && !@user_exists - user.add_role :pending - - # Inform admins that a user signed up if emails are turned on - send_approval_user_signup_email(user) if Rails.configuration.enable_email_verification - - return redirect_to root_path, flash: { success: I18n.t("registration.approval.signup") } - end - - send_invite_user_signup_email(user) if Rails.configuration.enable_email_verification && - invite_registration && !@user_exists - - login(user) - rescue => e - logger.error "Error authenticating via omniauth: #{e}" - omniauth_fail - end + process_signin end # POST /auth/failure @@ -81,6 +58,34 @@ class SessionsController < ApplicationController redirect_to root_path, alert: I18n.t(params[:message], default: I18n.t("omniauth_error")) end + # GET /auth/ldap + def ldap + ldap_config = {} + ldap_config[:host] = ENV['LDAP_SERVER'] + ldap_config[:port] = ENV['LDAP_PORT'].to_i != 0 ? ENV['LDAP_PORT'].to_i : 389 + ldap_config[:bind_dn] = ENV['LDAP_BIND_DN'] + ldap_config[:password] = ENV['LDAP_PASSWORD'] + ldap_config[:encryption] = if ENV['LDAP_METHOD'] == 'ssl' + 'simple_tls' + elsif ENV['LDAP_METHOD'] == 'tls' + 'start_tls' + end + ldap_config[:base] = ENV['LDAP_BASE'] + ldap_config[:uid] = ENV['LDAP_UID'] + + result = send_ldap_request(params[:session], ldap_config) + + if result + result = result.first + else + return redirect_to(ldap_signin_path, alert: I18n.t("invalid_credentials")) + end + + @auth = parse_auth(result) + + process_signin + end + private def session_params @@ -99,4 +104,47 @@ class SessionsController < ApplicationController invitation = check_user_invited("", session[:invite_token], @user_domain) invitation[:present] end + + def process_signin + begin + @user_exists = check_user_exists + + if !@user_exists && @auth['provider'] == "twitter" + return redirect_to root_path, flash: { alert: I18n.t("registration.deprecated.twitter_signup") } + end + + # If using invitation registration method, make sure user is invited + return redirect_to root_path, flash: { alert: I18n.t("registration.invite.no_invite") } unless passes_invite_reqs + + user = User.from_omniauth(@auth) + + # Add pending role if approval method and is a new user + if approval_registration && !@user_exists + user.add_role :pending + + # Inform admins that a user signed up if emails are turned on + send_approval_user_signup_email(user) if Rails.configuration.enable_email_verification + + return redirect_to root_path, flash: { success: I18n.t("registration.approval.signup") } + end + + send_invite_user_signup_email(user) if Rails.configuration.enable_email_verification && + invite_registration && !@user_exists + + login(user) + + if @auth['provider'] == "twitter" + flash[:alert] = if allow_user_signup? && allow_greenlight_accounts? + I18n.t("registration.deprecated.twitter_signin", + link: signup_path(old_twitter_user_id: user.id)) + else + I18n.t("registration.deprecated.twitter_signin", + link: signin_path(old_twitter_user_id: user.id)) + end + end + rescue => e + logger.error "Error authenticating via omniauth: #{e}" + omniauth_fail + end + end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4b2ba771..dd89d633 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -62,6 +62,14 @@ class UsersController < ApplicationController # GET /signin def signin + unless params[:old_twitter_user_id].nil? && session[:old_twitter_user_id].nil? + flash[:alert] = I18n.t("registration.deprecated.new_signin") + session[:old_twitter_user_id] = params[:old_twitter_user_id] unless params[:old_twitter_user_id].nil? + end + end + + # GET /ldap_signin + def ldap_signin end # GET /signup @@ -75,6 +83,12 @@ class UsersController < ApplicationController session[:invite_token] = params[:invite_token] end + unless params[:old_twitter_user_id].nil? && session[:old_twitter_user_id].nil? + logout + flash.now[:alert] = I18n.t("registration.deprecated.new_signin") + session[:old_twitter_user_id] = params[:old_twitter_user_id] unless params[:old_twitter_user_id].nil? + end + @user = User.new end @@ -175,7 +189,7 @@ class UsersController < ApplicationController end def ensure_unauthenticated - redirect_to current_user.main_room if current_user + redirect_to current_user.main_room if current_user && params[:old_twitter_user_id].nil? end def user_params diff --git a/app/helpers/admins_helper.rb b/app/helpers/admins_helper.rb index ab430e71..af23f731 100644 --- a/app/helpers/admins_helper.rb +++ b/app/helpers/admins_helper.rb @@ -53,4 +53,8 @@ module AdminsHelper I18n.t("administrator.site_settings.registration.methods.approval") end end + + def room_limit_number + Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Limit").to_i + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9ae09ecb..eb3ebf65 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -17,10 +17,12 @@ # with BigBlueButton; if not, see . require 'bbb_api' +require 'i18n/language/mapping' module ApplicationHelper include MeetingsHelper include BbbApi + include I18n::Language::Mapping # Gets all configured omniauth providers. def configured_providers @@ -31,12 +33,20 @@ module ApplicationHelper # Determines which providers can show a login button in the login modal. def iconset_providers - configured_providers & [:google, :twitter, :microsoft_office365] + providers = configured_providers & [:google, :twitter, :microsoft_office365, :ldap] + + providers.delete(:twitter) if session[:old_twitter_user_id] + + providers end # Generates the login URL for a specific provider. def omniauth_login_url(provider) - "#{Rails.configuration.relative_url_root}/auth/#{provider}" + if provider == :ldap + ldap_signin_path + else + "#{Rails.configuration.relative_url_root}/auth/#{provider}" + end end # Determine if Greenlight is configured to allow user signups. @@ -54,9 +64,8 @@ module ApplicationHelper locales = I18n.available_locales language_opts = [['<<<< ' + t("language_default") + ' >>>>', "default"]] locales.each do |locale| - language_name = t("language_name", locale: locale) - language_name = locale.to_s if locale != :en && language_name == 'English' - language_opts.push([language_name, locale.to_s]) + language_mapping = I18n::Language::Mapping.language_mapping_list[locale.to_s.gsub("_", "-")] + language_opts.push([language_mapping["nativeName"], locale.to_s]) end language_opts.sort end diff --git a/app/helpers/rooms_helper.rb b/app/helpers/rooms_helper.rb index e355a8e5..009fd77d 100644 --- a/app/helpers/rooms_helper.rb +++ b/app/helpers/rooms_helper.rb @@ -27,4 +27,28 @@ module RoomsHelper Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Authentication") == "true" && current_user.nil? end + + def number_of_rooms_allowed + Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Limit").to_i + end + + def room_limit_exceeded + limit = Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Limit").to_i + + # Does not apply to admin or users that aren't signed in + # 15+ option is used as unlimited + return false if current_user&.has_role?(:admin) || limit == 15 + + current_user.rooms.length >= limit + end + + def current_room_exceeds_limit(room) + # Get how many rooms need to be deleted to reach allowed room number + limit = Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Limit").to_i + + return false if current_user&.has_role?(:admin) || limit == 15 + + @diff = current_user.rooms.count - limit + @diff.positive? && current_user.rooms.pluck(:id).index(room.id) + 1 > limit + end end diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb index dd4263cf..d21573f5 100644 --- a/app/helpers/sessions_helper.rb +++ b/app/helpers/sessions_helper.rb @@ -19,6 +19,8 @@ module SessionsHelper # Logs a user into GreenLight. def login(user) + migrate_twitter_user(user) + session[:user_id] = user.id # If there are not terms, or the user has accepted them, check for email verification @@ -76,17 +78,27 @@ module SessionsHelper end def omniauth_options(env) - gl_redirect_url = (Rails.env.production? ? "https" : env["rack.url_scheme"]) + "://" + env["SERVER_NAME"] + ":" + - env["SERVER_PORT"] - user_domain = parse_user_domain(env["SERVER_NAME"]) - env['omniauth.strategy'].options[:customer] = user_domain - env['omniauth.strategy'].options[:gl_redirect_url] = gl_redirect_url - env['omniauth.strategy'].options[:default_callback_url] = Rails.configuration.gl_callback_url - env['omniauth.strategy'].options[:checksum] = generate_checksum(user_domain, gl_redirect_url, - Rails.configuration.launcher_secret) + if env['omniauth.strategy'].options[:name] == "bn-launcher" + protocol = Rails.env.production? ? "https" : env["rack.url_scheme"] + + customer_redirect_url = protocol + "://" + env["SERVER_NAME"] + ":" + + env["SERVER_PORT"] + user_domain = parse_user_domain(env["SERVER_NAME"]) + env['omniauth.strategy'].options[:customer] = user_domain + env['omniauth.strategy'].options[:customer_redirect_url] = customer_redirect_url + env['omniauth.strategy'].options[:default_callback_url] = Rails.configuration.gl_callback_url + + # This is only used in the old launcher and should eventually be removed + env['omniauth.strategy'].options[:checksum] = generate_checksum(user_domain, customer_redirect_url, + Rails.configuration.launcher_secret) + elsif env['omniauth.strategy'].options[:name] == "google" + set_hd(env, ENV['GOOGLE_OAUTH2_HD']) + elsif env['omniauth.strategy'].options[:name] == "office365" + set_hd(env, ENV['OFFICE365_HD']) + end end - def google_omniauth_hd(env, hd) + def set_hd(env, hd) hd_opts = hd.split(',') env['omniauth.strategy'].options[:hd] = if hd_opts.empty? @@ -97,4 +109,24 @@ module SessionsHelper hd_opts end end + + def migrate_twitter_user(user) + if !session["old_twitter_user_id"].nil? && user.provider != "twitter" + old_user = User.find(session["old_twitter_user_id"]) + + old_user.rooms.each do |room| + room.owner = user + + room.name = "Old " + room.name if room.id == old_user.main_room.id + + room.save! + end + + # Query for the old user again so the migrated rooms don't get deleted + old_user.reload + old_user.destroy! + + session["old_twitter_user_id"] = nil + end + end end diff --git a/app/models/setting.rb b/app/models/setting.rb index b4f07ff0..82f395f5 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -41,6 +41,8 @@ class Setting < ApplicationRecord Rails.configuration.registration_method_default when "Room Authentication" false + when "Room Limit" + Rails.configuration.number_of_rooms_default end end end diff --git a/app/models/user.rb b/app/models/user.rb index 2966e22e..f7af9a35 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -70,7 +70,7 @@ class User < ApplicationRecord # Provider attributes. def auth_name(auth) case auth['provider'] - when :microsoft_office365 + when :office365 auth['info']['display_name'] else auth['info']['name'] @@ -97,7 +97,7 @@ class User < ApplicationRecord when :twitter auth['info']['image'].gsub("http", "https").gsub("_normal", "") else - auth['info']['image'] unless auth['provider'] == :microsoft_office365 + auth['info']['image'] end end end diff --git a/app/views/admins/index.html.erb b/app/views/admins/index.html.erb index c3af385a..f52a799d 100644 --- a/app/views/admins/index.html.erb +++ b/app/views/admins/index.html.erb @@ -12,6 +12,11 @@ # You should have received a copy of the GNU Lesser General Public License along # with BigBlueButton; if not, see . %> + +<% # Only load the color picker on the Admins page %> +<%= stylesheet_link_tag "https://cdn.jsdelivr.net/npm/@simonwep/pickr/dist/themes/monolith.min.css" %> +<%= javascript_include_tag "https://cdn.jsdelivr.net/npm/@simonwep/pickr/dist/pickr.min.js" %> +
<%= render "shared/components/subtitle", subtitle: t("administrator.title"), search: false %> diff --git a/app/views/errors/bigbluebutton_error.html.erb b/app/views/errors/bigbluebutton_error.html.erb index b1e41b6b..f30cdd8e 100644 --- a/app/views/errors/bigbluebutton_error.html.erb +++ b/app/views/errors/bigbluebutton_error.html.erb @@ -14,7 +14,7 @@ %>
-
<%= I18n.t("errors.bigbluebutton.title") %>
-

<%= I18n.t("errors.bigbluebutton.message") %>

-

<%= I18n.t("errors.bigbluebutton.help", doc_link: "http://docs.bigbluebutton.org/greenlight/gl-install.html#setting-bigbluebutton-credentials").html_safe %>

+
<%= t("errors.bigbluebutton.title") %>
+

<%= t("errors.bigbluebutton.message") %>

+

<%= t("errors.bigbluebutton.help", doc_link: "http://docs.bigbluebutton.org/greenlight/gl-install.html#setting-bigbluebutton-credentials").html_safe %>

diff --git a/app/views/errors/internal_error.html.erb b/app/views/errors/internal_error.html.erb index af926b5b..0c76f1db 100644 --- a/app/views/errors/internal_error.html.erb +++ b/app/views/errors/internal_error.html.erb @@ -14,7 +14,7 @@ %>
-
500
+
500

<%= t("errors.internal.message") %>

<%= t("errors.internal.help") %>

diff --git a/app/views/errors/not_found.html.erb b/app/views/errors/not_found.html.erb index 647e34c8..d259ceac 100644 --- a/app/views/errors/not_found.html.erb +++ b/app/views/errors/not_found.html.erb @@ -14,10 +14,15 @@ %>
-
404
-

<%= t("errors.not_found.message") %>

-

<%= t("errors.not_found.help") %>

-
- <%= t("go_back") %> - +
404
+ <% if defined?(message) && defined?(help) %> +

<%= message %>

+

<%= help %>

+ <% else %> +

<%= t("errors.not_found.message") %>

+

<%= t("errors.not_found.help") %>

+ + <%= t("go_back") %> + + <% end %>
diff --git a/app/views/errors/unauthorized.html.erb b/app/views/errors/unauthorized.html.erb index 1e6682a8..23dcdd7d 100644 --- a/app/views/errors/unauthorized.html.erb +++ b/app/views/errors/unauthorized.html.erb @@ -14,7 +14,7 @@ %>
-
401
-

<%= I18n.t("errors.unauthorized.message") %>

-

<%= I18n.t("errors.unauthorized.help") %>

+
401
+

<%= t("errors.unauthorized.message") %>

+

<%= t("errors.unauthorized.help") %>

diff --git a/app/views/errors/unprocessable.html.erb b/app/views/errors/unprocessable.html.erb deleted file mode 100644 index cec62f44..00000000 --- a/app/views/errors/unprocessable.html.erb +++ /dev/null @@ -1,23 +0,0 @@ -<% -# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/. -# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below). -# This program is free software; you can redistribute it and/or modify it under the -# terms of the GNU Lesser General Public License as published by the Free Software -# Foundation; either version 3.0 of the License, or (at your option) any later -# version. -# -# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. -# You should have received a copy of the GNU Lesser General Public License along -# with BigBlueButton; if not, see . -%> - -
-
422
-

<%= t("errors.unprocessable.message") %>

-

<%= t("errors.unprocessable.help") %>

- - <%= t("go_back") %> - -
diff --git a/app/views/rooms/show.html.erb b/app/views/rooms/show.html.erb index e9b76d47..d527be81 100644 --- a/app/views/rooms/show.html.erb +++ b/app/views/rooms/show.html.erb @@ -13,54 +13,65 @@ # with BigBlueButton; if not, see . %> +<% exceeds_limit = current_room_exceeds_limit(@room)%> +<% if exceeds_limit%> +
+ <%= t("room.room_limit_exceeded", difference: @diff) %> +
+<% end %>
-

<%= @room.name %>

<% if current_user.main_room == @room %> +

<%= t("home_room") %>

<% else %> +

<%= @room.name %>

<% end %>

<%= @room.sessions %> <%= t("room.sessions") %> | <%= @recordings.length %> <%= t("room.recordings") %>

- -
-
- -
-
-
-
- - - <%= t("copy") %> - + <% unless exceeds_limit %> + +
+
+ -
- <% if Rails.configuration.enable_google_calendar_button %> - - - <%= t("add_to_google_calendar") %> +
+
+
+ +
+ <% if Rails.configuration.enable_google_calendar_button %> + + + <%= t("add_to_google_calendar") %> + + <% end %> +
-
+ <% end %>
<% if @is_running %> <%= button_to t("room.join"), room_path(@room), class: "btn btn-primary btn-block px-7 start-button float-right" %> <% else %> - <%= button_to t("room.start"), start_room_path(@room), class: "btn btn-primary btn-block px-7 start-button float-right" %> + <% unless exceeds_limit %> + <%= button_to t("room.start"), start_room_path(@room), class: "btn btn-primary btn-block px-7 start-button float-right" %> + <% end %> <% end %>
@@ -81,7 +92,9 @@ <%= render "shared/modals/delete_room_modal", room: room %> <% end %> <% end %> - <%= render "shared/components/create_room_block"%> + <% unless room_limit_exceeded %> + <%= render "shared/components/create_room_block"%> + <% end %>
diff --git a/app/views/shared/_flash_messages.html.erb b/app/views/shared/_flash_messages.html.erb index 6d410e0c..6e863608 100644 --- a/app/views/shared/_flash_messages.html.erb +++ b/app/views/shared/_flash_messages.html.erb @@ -17,17 +17,17 @@ <% if key.eql? "success" %>
- <%= value %> + <%= value.html_safe %>
<% elsif key.eql? "alert" %>
- <%= value %> + <%= value.html_safe %>
<% elsif key.eql? "info" %>
- <%= value %> + <%= value.html_safe %>
<% end %> <% end %> diff --git a/app/views/shared/_footer.html.erb b/app/views/shared/_footer.html.erb index f9867aa1..792bc997 100755 --- a/app/views/shared/_footer.html.erb +++ b/app/views/shared/_footer.html.erb @@ -14,7 +14,7 @@ %>
-

<%= t("footer.powered_by", href: link_to(t("greenlight"), "https://bigbluebutton.org/2018/07/09/greenlight-2-0/", target: "_blank")).html_safe %> v <%= Greenlight::Application::VERSION %>

+

<%= t("footer.powered_by", href: link_to(t("greenlight"), "https://bigbluebutton.org/2018/07/09/greenlight-2-0/", target: "_blank")).html_safe %> <%= Greenlight::Application::VERSION %>

<%= render "shared/components/cookie_warning" %> diff --git a/app/views/shared/_header.html.erb b/app/views/shared/_header.html.erb index a11211df..1228e2b4 100755 --- a/app/views/shared/_header.html.erb +++ b/app/views/shared/_header.html.erb @@ -72,9 +72,7 @@
<% else %> <% allow_greenlight_accounts = allow_greenlight_accounts? %> - <% if Rails.configuration.omniauth_ldap %> - <%= link_to t("login"), omniauth_login_url(:ldap), :class => "btn btn-outline-primary mx-2 sign-in-button" %> - <% elsif allow_greenlight_accounts %> + <% if allow_greenlight_accounts %> <%= link_to t("login"), signin_path, :class => "btn btn-outline-primary mx-2 sign-in-button" %> <% elsif Rails.configuration.loadbalanced_configuration %> <%= link_to t("login"), omniauth_login_url(:bn_launcher), :class => "btn btn-outline-primary mx-2 sign-in-button" %> diff --git a/app/views/shared/admin_settings/_site_settings.html.erb b/app/views/shared/admin_settings/_site_settings.html.erb index 62d124f1..e9721d84 100644 --- a/app/views/shared/admin_settings/_site_settings.html.erb +++ b/app/views/shared/admin_settings/_site_settings.html.erb @@ -78,7 +78,7 @@
-
+
@@ -99,4 +99,38 @@
+
+
+
+ + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
diff --git a/app/views/shared/admin_settings/_users.html.erb b/app/views/shared/admin_settings/_users.html.erb index f0ce668c..df8422fa 100644 --- a/app/views/shared/admin_settings/_users.html.erb +++ b/app/views/shared/admin_settings/_users.html.erb @@ -21,7 +21,7 @@
- +
+
"> @@ -69,7 +69,7 @@
<%= user.name %>
<%= [t("administrator.users.table.created"), ": ", user.created_at].join %>
-
<%= user.email && user.email != "" ? user.email : user.username%><%= user.email && user.email != "" ? user.email : user.username%> <%= user.provider %> <% roles = user.roles().pluck(:name) %> diff --git a/app/views/shared/components/_room_block.html.erb b/app/views/shared/components/_room_block.html.erb index 167f3fb0..9e8c6fc4 100644 --- a/app/views/shared/components/_room_block.html.erb +++ b/app/views/shared/components/_room_block.html.erb @@ -28,7 +28,11 @@
-

<%= room.name %>

+ <% if room == current_user.main_room %> +

<%= t("home_room") %>

+ <% else %> +

<%= room.name %>

+ <% end %>