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

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