GRN-88: Fixed some things that Scrutinizer was complaining about (#433)

* Scrutinizer fixes

* Moved helper code to concern

* Another scrutinizer fix

* User controller conflict fix

* Another user controller fix

* Added include verifier
This commit is contained in:
farhatahmad 2019-04-11 10:25:49 -04:00 committed by Jesus Federico
parent 5e3aa72955
commit 88776eaadb
6 changed files with 37 additions and 15 deletions

View File

@ -145,7 +145,6 @@ $(document).on('turbolinks:load', function(){
// Elements that can be renamed // Elements that can be renamed
var room_title = $('#room-title'); var room_title = $('#room-title');
var room_blocks = $('#room_block_container').find('a');
var recording_rows = $('#recording-table').find('tr'); var recording_rows = $('#recording-table').find('tr');
// Configure renaming for room header // Configure renaming for room header

View File

@ -62,13 +62,13 @@ $(document).on('turbolinks:load', function(){
//show all elements & their children with a create-only class //show all elements & their children with a create-only class
$(".create-only").each(function() { $(".create-only").each(function() {
$(this).show() $(this).show()
if($(this).children().length > 0) $(this).children().show() if($(this).children().length > 0) { $(this).children().show() }
}) })
//hide all elements & their children with a update-only class //hide all elements & their children with a update-only class
$(".update-only").each(function() { $(".update-only").each(function() {
$(this).attr('style',"display:none !important") $(this).attr('style',"display:none !important")
if($(this).children().length > 0) $(this).children().attr('style',"display:none !important") if($(this).children().length > 0) { $(this).children().attr('style',"display:none !important") }
}) })
}) })
@ -81,13 +81,13 @@ $(document).on('turbolinks:load', function(){
//show all elements & their children with a update-only class //show all elements & their children with a update-only class
$(".update-only").each(function() { $(".update-only").each(function() {
$(this).show() $(this).show()
if($(this).children().length > 0) $(this).children().show() if($(this).children().length > 0) { $(this).children().show() }
}) })
//hide all elements & their children with a create-only class //hide all elements & their children with a create-only class
$(".create-only").each(function() { $(".create-only").each(function() {
$(this).attr('style',"display:none !important") $(this).attr('style',"display:none !important")
if($(this).children().length > 0) $(this).children().attr('style',"display:none !important") if($(this).children().length > 0) { $(this).children().attr('style',"display:none !important") }
}) })
updateCurrentSettings($(this).closest("#room-block").data("room-settings")) updateCurrentSettings($(this).closest("#room-block").data("room-settings"))
@ -105,7 +105,7 @@ $(document).on('turbolinks:load', function(){
//set dropdown value //set dropdown value
if (settings.joinViaHtml5) { if (settings.joinViaHtml5) {
updateDropdown($(".dropdown-item[value='html5']")) updateDropdown($(".dropdown-item[value='html5']"))
} else if (settings.joinViaHtml5 == false) { } else if (settings.joinViaHtml5 === false) {
updateDropdown($(".dropdown-item[value='flash']")) updateDropdown($(".dropdown-item[value='flash']"))
} else { //default option } else { //default option
updateDropdown($(".dropdown-item[value='default']")) updateDropdown($(".dropdown-item[value='default']"))

View File

@ -92,6 +92,8 @@ $(document).on('turbolinks:load', function(){
} }
else if(order === "desc"){ else if(order === "desc"){
return b_val.localeCompare(a_val); return b_val.localeCompare(a_val);
} else {
return undefined;
} }

View File

@ -17,6 +17,8 @@
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. # with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
class AccountActivationsController < ApplicationController class AccountActivationsController < ApplicationController
include Verifier
before_action :ensure_unauthenticated before_action :ensure_unauthenticated
before_action :find_user before_action :find_user
@ -44,7 +46,7 @@ class AccountActivationsController < ApplicationController
flash[:alert] = I18n.t("verify.already_verified") flash[:alert] = I18n.t("verify.already_verified")
else else
begin begin
@user.send_activation_email(verification_link) @user.send_activation_email(user_verification_link)
rescue => e rescue => e
logger.error "Error in email delivery: #{e}" logger.error "Error in email delivery: #{e}"
flash[:alert] = I18n.t(params[:message], default: I18n.t("delivery_error")) flash[:alert] = I18n.t(params[:message], default: I18n.t("delivery_error"))
@ -58,10 +60,6 @@ class AccountActivationsController < ApplicationController
private private
def verification_link
request.base_url + edit_account_activation_path(token: @user.activation_token, email: @user.email)
end
def ensure_unauthenticated def ensure_unauthenticated
redirect_to current_user.main_room if current_user redirect_to current_user.main_room if current_user
end end

View File

@ -0,0 +1,26 @@
# 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 Verifier
extend ActiveSupport::Concern
# Returns the link the user needs to click to verify their account
def user_verification_link
request.base_url + edit_account_activation_path(token: @user.activation_token, email: @user.email)
end
end

View File

@ -18,6 +18,7 @@
class UsersController < ApplicationController class UsersController < ApplicationController
include RecordingsHelper include RecordingsHelper
include Verifier
before_action :find_user, only: [:edit, :update, :destroy] before_action :find_user, only: [:edit, :update, :destroy]
before_action :ensure_unauthenticated, only: [:new, :create] before_action :ensure_unauthenticated, only: [:new, :create]
@ -141,10 +142,6 @@ class UsersController < ApplicationController
@user = User.find_by!(uid: params[:user_uid]) @user = User.find_by!(uid: params[:user_uid])
end end
def verification_link
request.base_url + edit_account_activation_path(token: @user.activation_token, email: @user.email)
end
def ensure_unauthenticated def ensure_unauthenticated
redirect_to current_user.main_room if current_user redirect_to current_user.main_room if current_user
end end