forked from External/greenlight
GRN2-196: Fixed issues that scrutinizer is complaining about (#765)
* Refactored code to improve scrutinizer score * Bug fixes
This commit is contained in:
@ -56,6 +56,10 @@ module Authenticator
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_unauthenticated_except_twitter
|
||||
redirect_to current_user.main_room if current_user && params[:old_twitter_user_id].nil?
|
||||
end
|
||||
|
||||
# Logs current user out of GreenLight.
|
||||
def logout
|
||||
session.delete(:user_id) if current_user
|
||||
|
94
app/controllers/concerns/joiner.rb
Normal file
94
app/controllers/concerns/joiner.rb
Normal file
@ -0,0 +1,94 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
module Joiner
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# Displays the join room page to the user
|
||||
def show_user_join
|
||||
# Get users name
|
||||
@name = if current_user
|
||||
current_user.name
|
||||
elsif cookies.encrypted[:greenlight_name]
|
||||
cookies.encrypted[:greenlight_name]
|
||||
else
|
||||
""
|
||||
end
|
||||
|
||||
@search, @order_column, @order_direction, pub_recs =
|
||||
public_recordings(@room.bbb_id, params.permit(:search, :column, :direction), true)
|
||||
|
||||
@pagy, @public_recordings = pagy_array(pub_recs)
|
||||
|
||||
render :join
|
||||
end
|
||||
|
||||
# create or update cookie to track the three most recent rooms a user joined
|
||||
def save_recent_rooms
|
||||
if current_user
|
||||
recently_joined_rooms = cookies.encrypted["#{current_user.uid}_recently_joined_rooms"].to_a
|
||||
cookies.encrypted["#{current_user.uid}_recently_joined_rooms"] =
|
||||
recently_joined_rooms.prepend(@room.id).uniq[0..2]
|
||||
end
|
||||
end
|
||||
|
||||
def join_room(opts)
|
||||
room_settings = JSON.parse(@room[:room_settings])
|
||||
|
||||
if room_running?(@room.bbb_id) || @room.owned_by?(current_user) || room_settings["anyoneCanStart"]
|
||||
|
||||
# Determine if the user needs to join as a moderator.
|
||||
opts[:user_is_moderator] = @room.owned_by?(current_user) || room_settings["joinModerator"]
|
||||
|
||||
opts[:require_moderator_approval] = room_settings["requireModeratorApproval"]
|
||||
|
||||
if current_user
|
||||
redirect_to join_path(@room, current_user.name, opts, current_user.uid)
|
||||
else
|
||||
join_name = params[:join_name] || params[@room.invite_path][:join_name]
|
||||
redirect_to join_path(@room, join_name, opts)
|
||||
end
|
||||
else
|
||||
search_params = params[@room.invite_path] || params
|
||||
@search, @order_column, @order_direction, pub_recs =
|
||||
public_recordings(@room.bbb_id, search_params.permit(:search, :column, :direction), true)
|
||||
|
||||
@pagy, @public_recordings = pagy_array(pub_recs)
|
||||
|
||||
# They need to wait until the meeting begins.
|
||||
render :wait
|
||||
end
|
||||
end
|
||||
|
||||
def incorrect_user_domain
|
||||
Rails.configuration.loadbalanced_configuration && @room.owner.provider != @user_domain
|
||||
end
|
||||
|
||||
# Default, unconfigured meeting options.
|
||||
def default_meeting_options
|
||||
invite_msg = I18n.t("invite_message")
|
||||
{
|
||||
user_is_moderator: false,
|
||||
meeting_logout_url: request.base_url + logout_room_path(@room),
|
||||
meeting_recorded: true,
|
||||
moderator_message: "#{invite_msg}\n\n#{request.base_url + room_path(@room)}",
|
||||
host: request.host,
|
||||
recording_default_visibility: @settings.get_value("Default Recording Visibility") == "public"
|
||||
}
|
||||
end
|
||||
end
|
@ -43,4 +43,33 @@ module Registrar
|
||||
{ present: false, verified: false }
|
||||
end
|
||||
end
|
||||
|
||||
# Checks if the user passes the requirements to be invited
|
||||
def passes_invite_reqs
|
||||
# check if user needs to be invited and IS invited
|
||||
invitation = check_user_invited(@user.email, session[:invite_token], @user_domain)
|
||||
|
||||
@user.email_verified = true if invitation[:verified]
|
||||
|
||||
invitation[:present]
|
||||
end
|
||||
|
||||
# Add validation errors to model if they exist
|
||||
def valid_user_or_captcha
|
||||
valid_user = @user.valid?
|
||||
valid_captcha = Rails.configuration.recaptcha_enabled ? verify_recaptcha(model: @user) : true
|
||||
|
||||
logger.error("Support: #{@user.email} creation failed: User params are not valid.") unless valid_user
|
||||
|
||||
valid_user && valid_captcha
|
||||
end
|
||||
|
||||
# Checks if the user trying to sign in with twitter account
|
||||
def check_if_twitter_account(log_out = false)
|
||||
unless params[:old_twitter_user_id].nil? && session[:old_twitter_user_id].nil?
|
||||
logout if log_out
|
||||
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
|
||||
end
|
||||
end
|
||||
|
@ -22,22 +22,20 @@ module Themer
|
||||
# Lightens a color by 40%
|
||||
def color_lighten(color)
|
||||
# Uses the built in Sass Engine to lighten the color
|
||||
|
||||
dummy_scss = "h1 { color: $lighten; }"
|
||||
compiled = SassC::Engine.new("$lighten:lighten(#{color}, 40%);" + dummy_scss, syntax: :scss).render
|
||||
|
||||
string_locater = 'color: '
|
||||
color_start = compiled.index(string_locater) + string_locater.length
|
||||
|
||||
compiled[color_start..color_start + 6]
|
||||
generate_sass("lighten", color, "40%")
|
||||
end
|
||||
|
||||
# Darkens a color by 10%
|
||||
def color_darken(color)
|
||||
# Uses the built in Sass Engine to darken the color
|
||||
generate_sass("darken", color, "10%")
|
||||
end
|
||||
|
||||
dummy_scss = "h1 { color: $darken; }"
|
||||
compiled = SassC::Engine.new("$darken:darken(#{color}, 10%);" + dummy_scss, syntax: :scss).render
|
||||
private
|
||||
|
||||
def generate_sass(action, color, percentage)
|
||||
dummy_scss = "h1 { color: $#{action}; }"
|
||||
compiled = SassC::Engine.new("$#{action}:#{action}(#{color}, #{percentage});" + dummy_scss, syntax: :scss).render
|
||||
|
||||
string_locater = 'color: '
|
||||
color_start = compiled.index(string_locater) + string_locater.length
|
||||
|
Reference in New Issue
Block a user