Skip to content
Snippets Groups Projects
Commit eaada9d7 authored by Mario de la Ossa's avatar Mario de la Ossa Committed by Sean McGivern
Browse files

use Gitlab::UserSettings directly as a singleton instead of including/extending it

parent 8fa2932d
No related branches found
No related tags found
No related merge requests found
Showing
with 43 additions and 62 deletions
class Admin::CohortsController < Admin::ApplicationController
def index
if current_application_settings.usage_ping_enabled
if Gitlab::CurrentSettings.usage_ping_enabled
cohorts_results = Rails.cache.fetch('cohorts', expires_in: 1.day) do
CohortsService.new.execute
end
Loading
Loading
Loading
Loading
@@ -2,7 +2,6 @@ require 'gon'
require 'fogbugz'
 
class ApplicationController < ActionController::Base
include Gitlab::CurrentSettings
include Gitlab::GonHelper
include GitlabRoutingHelper
include PageLayoutHelper
Loading
Loading
@@ -28,7 +27,7 @@ class ApplicationController < ActionController::Base
 
protect_from_forgery with: :exception
 
helper_method :can?, :current_application_settings
helper_method :can?
helper_method :import_sources_enabled?, :github_import_enabled?, :gitea_import_enabled?, :github_import_configured?, :gitlab_import_enabled?, :gitlab_import_configured?, :bitbucket_import_enabled?, :bitbucket_import_configured?, :google_code_import_enabled?, :fogbugz_import_enabled?, :git_import_enabled?, :gitlab_project_import_enabled?
 
rescue_from Encoding::CompatibilityError do |exception|
Loading
Loading
@@ -120,7 +119,7 @@ class ApplicationController < ActionController::Base
end
 
def after_sign_out_path_for(resource)
current_application_settings.after_sign_out_path.presence || new_user_session_path
Gitlab::CurrentSettings.after_sign_out_path.presence || new_user_session_path
end
 
def can?(object, action, subject = :global)
Loading
Loading
@@ -268,15 +267,15 @@ class ApplicationController < ActionController::Base
end
 
def import_sources_enabled?
!current_application_settings.import_sources.empty?
!Gitlab::CurrentSettings.import_sources.empty?
end
 
def github_import_enabled?
current_application_settings.import_sources.include?('github')
Gitlab::CurrentSettings.import_sources.include?('github')
end
 
def gitea_import_enabled?
current_application_settings.import_sources.include?('gitea')
Gitlab::CurrentSettings.import_sources.include?('gitea')
end
 
def github_import_configured?
Loading
Loading
@@ -284,7 +283,7 @@ class ApplicationController < ActionController::Base
end
 
def gitlab_import_enabled?
request.host != 'gitlab.com' && current_application_settings.import_sources.include?('gitlab')
request.host != 'gitlab.com' && Gitlab::CurrentSettings.import_sources.include?('gitlab')
end
 
def gitlab_import_configured?
Loading
Loading
@@ -292,7 +291,7 @@ class ApplicationController < ActionController::Base
end
 
def bitbucket_import_enabled?
current_application_settings.import_sources.include?('bitbucket')
Gitlab::CurrentSettings.import_sources.include?('bitbucket')
end
 
def bitbucket_import_configured?
Loading
Loading
@@ -300,19 +299,19 @@ class ApplicationController < ActionController::Base
end
 
def google_code_import_enabled?
current_application_settings.import_sources.include?('google_code')
Gitlab::CurrentSettings.import_sources.include?('google_code')
end
 
def fogbugz_import_enabled?
current_application_settings.import_sources.include?('fogbugz')
Gitlab::CurrentSettings.import_sources.include?('fogbugz')
end
 
def git_import_enabled?
current_application_settings.import_sources.include?('git')
Gitlab::CurrentSettings.import_sources.include?('git')
end
 
def gitlab_project_import_enabled?
current_application_settings.import_sources.include?('gitlab_project')
Gitlab::CurrentSettings.import_sources.include?('gitlab_project')
end
 
# U2F (universal 2nd factor) devices need a unique identifier for the application
Loading
Loading
Loading
Loading
@@ -20,13 +20,13 @@ module EnforcesTwoFactorAuthentication
end
 
def two_factor_authentication_required?
current_application_settings.require_two_factor_authentication? ||
Gitlab::CurrentSettings.require_two_factor_authentication? ||
current_user.try(:require_two_factor_authentication_from_group?)
end
 
def two_factor_authentication_reason(global: -> {}, group: -> {})
if two_factor_authentication_required?
if current_application_settings.require_two_factor_authentication?
if Gitlab::CurrentSettings.require_two_factor_authentication?
global.call
else
groups = current_user.expanded_groups_requiring_two_factor_authentication.reorder(name: :asc)
Loading
Loading
@@ -36,7 +36,7 @@ module EnforcesTwoFactorAuthentication
end
 
def two_factor_grace_period
periods = [current_application_settings.two_factor_grace_period]
periods = [Gitlab::CurrentSettings.two_factor_grace_period]
periods << current_user.two_factor_grace_period if current_user.try(:require_two_factor_authentication_from_group?)
periods.min
end
Loading
Loading
module RequiresWhitelistedMonitoringClient
extend ActiveSupport::Concern
 
include Gitlab::CurrentSettings
included do
before_action :validate_ip_whitelisted_or_valid_token!
end
Loading
Loading
@@ -26,7 +24,7 @@ module RequiresWhitelistedMonitoringClient
token.present? &&
ActiveSupport::SecurityUtils.variable_size_secure_compare(
token,
current_application_settings.health_check_access_token
Gitlab::CurrentSettings.health_check_access_token
)
end
 
Loading
Loading
Loading
Loading
@@ -51,7 +51,7 @@ class InvitesController < ApplicationController
return if current_user
 
notice = "To accept this invitation, sign in"
notice << " or create an account" if current_application_settings.allow_signup?
notice << " or create an account" if Gitlab::CurrentSettings.allow_signup?
notice << "."
 
store_location_for :user, request.fullpath
Loading
Loading
Loading
Loading
@@ -10,6 +10,6 @@ class KodingController < ApplicationController
private
 
def check_integration!
render_404 unless current_application_settings.koding_enabled?
render_404 unless Gitlab::CurrentSettings.koding_enabled?
end
end
class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
include Gitlab::CurrentSettings
include Gitlab::GonHelper
include PageLayoutHelper
include OauthApplications
Loading
Loading
@@ -31,7 +30,7 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
private
 
def verify_user_oauth_applications_enabled
return if current_application_settings.user_oauth_applications?
return if Gitlab::CurrentSettings.user_oauth_applications?
 
redirect_to profile_path
end
Loading
Loading
Loading
Loading
@@ -145,7 +145,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
label = Gitlab::OAuth::Provider.label_for(oauth['provider'])
message = "Signing in using your #{label} account without a pre-existing GitLab account is not allowed."
 
if current_application_settings.allow_signup?
if Gitlab::CurrentSettings.allow_signup?
message << " Create a GitLab account first, and then connect it to your #{label} account."
end
 
Loading
Loading
class PasswordsController < Devise::PasswordsController
include Gitlab::CurrentSettings
skip_before_action :require_no_authentication, only: [:edit, :update]
 
before_action :resource_from_email, only: [:create]
Loading
Loading
@@ -46,7 +44,7 @@ class PasswordsController < Devise::PasswordsController
if resource
return if resource.allow_password_authentication?
else
return if current_application_settings.password_authentication_enabled?
return if Gitlab::CurrentSettings.password_authentication_enabled?
end
 
redirect_to after_sending_reset_password_instructions_path_for(resource_name),
Loading
Loading
Loading
Loading
@@ -394,7 +394,7 @@ class ProjectsController < Projects::ApplicationController
end
 
def project_export_enabled
render_404 unless current_application_settings.project_export_enabled?
render_404 unless Gitlab::CurrentSettings.project_export_enabled?
end
 
def redirect_git_extension
Loading
Loading
Loading
Loading
@@ -23,7 +23,7 @@ class RootController < Dashboard::ProjectsController
 
def redirect_unlogged_user
if redirect_to_home_page_url?
redirect_to(current_application_settings.home_page_url)
redirect_to(Gitlab::CurrentSettings.home_page_url)
else
redirect_to(new_user_session_path)
end
Loading
Loading
@@ -48,9 +48,9 @@ class RootController < Dashboard::ProjectsController
def redirect_to_home_page_url?
# If user is not signed-in and tries to access root_path - redirect him to landing page
# Don't redirect to the default URL to prevent endless redirections
return false unless current_application_settings.home_page_url.present?
return false unless Gitlab::CurrentSettings.home_page_url.present?
 
home_page_url = current_application_settings.home_page_url.chomp('/')
home_page_url = Gitlab::CurrentSettings.home_page_url.chomp('/')
root_urls = [Gitlab.config.gitlab['url'].chomp('/'), root_url.chomp('/')]
 
root_urls.exclude?(home_page_url)
Loading
Loading
module ApplicationSettingsHelper
extend self
 
include Gitlab::CurrentSettings
delegate :allow_signup?,
:gravatar_enabled?,
:password_authentication_enabled_for_web?,
:akismet_enabled?,
:koding_enabled?,
to: :current_application_settings
to: :'Gitlab::CurrentSettings.current_application_settings'
 
def user_oauth_applications?
current_application_settings.user_oauth_applications
Gitlab::CurrentSettings.user_oauth_applications
end
 
def allowed_protocols_present?
current_application_settings.enabled_git_access_protocol.present?
Gitlab::CurrentSettings.enabled_git_access_protocol.present?
end
 
def enabled_protocol
case current_application_settings.enabled_git_access_protocol
case Gitlab::CurrentSettings.enabled_git_access_protocol
when 'http'
gitlab_config.protocol
when 'ssh'
Loading
Loading
@@ -57,7 +55,7 @@ module ApplicationSettingsHelper
# toggle button effect.
def import_sources_checkboxes(help_block_id)
Gitlab::ImportSources.options.map do |name, source|
checked = current_application_settings.import_sources.include?(source)
checked = Gitlab::CurrentSettings.import_sources.include?(source)
css_class = checked ? 'active' : ''
checkbox_name = 'application_setting[import_sources][]'
 
Loading
Loading
@@ -72,7 +70,7 @@ module ApplicationSettingsHelper
 
def oauth_providers_checkboxes
button_based_providers.map do |source|
disabled = current_application_settings.disabled_oauth_sign_in_sources.include?(source.to_s)
disabled = Gitlab::CurrentSettings.disabled_oauth_sign_in_sources.include?(source.to_s)
css_class = 'btn'
css_class << ' active' unless disabled
checkbox_name = 'application_setting[enabled_oauth_sign_in_sources][]'
Loading
Loading
module AuthHelper
include Gitlab::CurrentSettings
PROVIDERS_WITH_ICONS = %w(twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2 authentiq).freeze
FORM_BASED_PROVIDERS = [/\Aldap/, 'crowd'].freeze
 
Loading
Loading
@@ -41,7 +39,7 @@ module AuthHelper
end
 
def enabled_button_based_providers
disabled_providers = current_application_settings.disabled_oauth_sign_in_sources || []
disabled_providers = Gitlab::CurrentSettings.disabled_oauth_sign_in_sources || []
 
button_based_providers.map(&:to_s) - disabled_providers
end
Loading
Loading
module ProjectsHelper
include Gitlab::CurrentSettings
def link_to_project(project)
link_to [project.namespace.becomes(Namespace), project], title: h(project.name) do
title = content_tag(:span, project.name, class: 'project-name')
Loading
Loading
@@ -214,7 +212,7 @@ module ProjectsHelper
project.cache_key,
controller.controller_name,
controller.action_name,
current_application_settings.cache_key,
Gitlab::CurrentSettings.cache_key,
'v2.5'
]
 
Loading
Loading
@@ -447,10 +445,10 @@ module ProjectsHelper
 
path = "#{import_path}?repo=#{repo}&branch=#{branch}&sha=#{sha}"
 
return URI.join(current_application_settings.koding_url, path).to_s
return URI.join(Gitlab::CurrentSettings.koding_url, path).to_s
end
 
current_application_settings.koding_url
Gitlab::CurrentSettings.koding_url
end
 
def contribution_guide_path(project)
Loading
Loading
@@ -559,7 +557,7 @@ module ProjectsHelper
def restricted_levels
return [] if current_user.admin?
 
current_application_settings.restricted_visibility_levels || []
Gitlab::CurrentSettings.restricted_visibility_levels || []
end
 
def project_permissions_settings(project)
Loading
Loading
module VersionCheckHelper
def version_status_badge
if Rails.env.production? && current_application_settings.version_check_enabled
if Rails.env.production? && Gitlab::CurrentSettings.version_check_enabled
image_url = VersionCheck.new.url
image_tag image_url, class: 'js-version-status-badge'
end
Loading
Loading
Loading
Loading
@@ -151,12 +151,12 @@ module VisibilityLevelHelper
def restricted_visibility_levels(show_all = false)
return [] if current_user.admin? && !show_all
 
current_application_settings.restricted_visibility_levels || []
Gitlab::CurrentSettings.restricted_visibility_levels || []
end
 
delegate :default_project_visibility,
:default_group_visibility,
to: :current_application_settings
to: :'Gitlab::CurrentSettings.current_application_settings'
 
def disallowed_visibility_level?(form_model, level)
return false unless form_model.respond_to?(:visibility_level_allowed?)
Loading
Loading
class AbuseReportMailer < BaseMailer
include Gitlab::CurrentSettings
def notify(abuse_report_id)
return unless deliverable?
 
@abuse_report = AbuseReport.find(abuse_report_id)
 
mail(
to: current_application_settings.admin_notification_email,
to: Gitlab::CurrentSettings.admin_notification_email,
subject: "#{@abuse_report.user.name} (#{@abuse_report.user.username}) was reported for abuse"
)
end
Loading
Loading
@@ -15,6 +13,6 @@ class AbuseReportMailer < BaseMailer
private
 
def deliverable?
current_application_settings.admin_notification_email.present?
Gitlab::CurrentSettings.admin_notification_email.present?
end
end
class BaseMailer < ActionMailer::Base
include Gitlab::CurrentSettings
around_action :render_with_default_locale
 
helper ApplicationHelper
helper MarkupHelper
 
attr_accessor :current_user
helper_method :current_user, :can?, :current_application_settings
helper_method :current_user, :can?
 
default from: proc { default_sender_address.format }
default reply_to: proc { default_reply_to_address.format }
Loading
Loading
module Clusters
module Platforms
class Kubernetes < ActiveRecord::Base
include Gitlab::CurrentSettings
include Gitlab::Kubernetes
include ReactiveCaching
 
Loading
Loading
@@ -169,7 +168,7 @@ module Clusters
{
token: token,
ca_pem: ca_pem,
max_session_time: current_application_settings.terminal_max_session_time
max_session_time: Gitlab::CurrentSettings.terminal_max_session_time
}
end
 
Loading
Loading
class IssueAssignee < ActiveRecord::Base
extend Gitlab::CurrentSettings
belongs_to :issue
belongs_to :assignee, class_name: "User", foreign_key: :user_id
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment