Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
af2f9307b0e3
Commit
af2f9307
authored
Feb 02, 2018
by
Mario de la Ossa
Browse files
use Gitlab::UserSettings directly as a singleton instead of including/extending it
parent
149231b8a5e8
Changes
96
Hide whitespace changes
Inline
Side-by-side
app/controllers/admin/cohorts_controller.rb
View file @
af2f9307
class
Admin::CohortsController
<
Admin
::
ApplicationController
def
index
if
current_application_s
ettings
.
usage_ping_enabled
if
Gitlab
::
CurrentS
ettings
.
usage_ping_enabled
cohorts_results
=
Rails
.
cache
.
fetch
(
'cohorts'
,
expires_in:
1
.
day
)
do
CohortsService
.
new
.
execute
end
...
...
app/controllers/application_controller.rb
View file @
af2f9307
...
...
@@ -2,7 +2,6 @@
require
'fogbugz'
class
ApplicationController
<
ActionController
::
Base
include
Gitlab
::
CurrentSettings
include
Gitlab
::
GonHelper
include
GitlabRoutingHelper
include
PageLayoutHelper
...
...
@@ -28,7 +27,7 @@
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
|
...
...
@@ -120,7 +119,7 @@
end
def
after_sign_out_path_for
(
resource
)
current_application_s
ettings
.
after_sign_out_path
.
presence
||
new_user_session_path
Gitlab
::
CurrentS
ettings
.
after_sign_out_path
.
presence
||
new_user_session_path
end
def
can?
(
object
,
action
,
subject
=
:global
)
...
...
@@ -268,7 +267,7 @@
end
def
import_sources_enabled?
!
current_application_s
ettings
.
import_sources
.
empty?
!
Gitlab
::
CurrentS
ettings
.
import_sources
.
empty?
end
def
github_import_enabled?
...
...
@@ -272,7 +271,7 @@
end
def
github_import_enabled?
current_application_s
ettings
.
import_sources
.
include?
(
'github'
)
Gitlab
::
CurrentS
ettings
.
import_sources
.
include?
(
'github'
)
end
def
gitea_import_enabled?
...
...
@@ -276,7 +275,7 @@
end
def
gitea_import_enabled?
current_application_s
ettings
.
import_sources
.
include?
(
'gitea'
)
Gitlab
::
CurrentS
ettings
.
import_sources
.
include?
(
'gitea'
)
end
def
github_import_configured?
...
...
@@ -284,7 +283,7 @@
end
def
gitlab_import_enabled?
request
.
host
!=
'gitlab.com'
&&
current_application_s
ettings
.
import_sources
.
include?
(
'gitlab'
)
request
.
host
!=
'gitlab.com'
&&
Gitlab
::
CurrentS
ettings
.
import_sources
.
include?
(
'gitlab'
)
end
def
gitlab_import_configured?
...
...
@@ -292,7 +291,7 @@
end
def
bitbucket_import_enabled?
current_application_s
ettings
.
import_sources
.
include?
(
'bitbucket'
)
Gitlab
::
CurrentS
ettings
.
import_sources
.
include?
(
'bitbucket'
)
end
def
bitbucket_import_configured?
...
...
@@ -300,7 +299,7 @@
end
def
google_code_import_enabled?
current_application_s
ettings
.
import_sources
.
include?
(
'google_code'
)
Gitlab
::
CurrentS
ettings
.
import_sources
.
include?
(
'google_code'
)
end
def
fogbugz_import_enabled?
...
...
@@ -304,7 +303,7 @@
end
def
fogbugz_import_enabled?
current_application_s
ettings
.
import_sources
.
include?
(
'fogbugz'
)
Gitlab
::
CurrentS
ettings
.
import_sources
.
include?
(
'fogbugz'
)
end
def
git_import_enabled?
...
...
@@ -308,7 +307,7 @@
end
def
git_import_enabled?
current_application_s
ettings
.
import_sources
.
include?
(
'git'
)
Gitlab
::
CurrentS
ettings
.
import_sources
.
include?
(
'git'
)
end
def
gitlab_project_import_enabled?
...
...
@@ -312,7 +311,7 @@
end
def
gitlab_project_import_enabled?
current_application_s
ettings
.
import_sources
.
include?
(
'gitlab_project'
)
Gitlab
::
CurrentS
ettings
.
import_sources
.
include?
(
'gitlab_project'
)
end
# U2F (universal 2nd factor) devices need a unique identifier for the application
...
...
app/controllers/concerns/enforces_two_factor_authentication.rb
View file @
af2f9307
...
...
@@ -20,9 +20,9 @@
end
def
two_factor_authentication_required?
current_application_s
ettings
.
require_two_factor_authentication?
||
Gitlab
::
CurrentS
ettings
.
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?
...
...
@@ -24,9 +24,9 @@
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_s
ettings
.
require_two_factor_authentication?
if
Gitlab
::
CurrentS
ettings
.
require_two_factor_authentication?
global
.
call
else
groups
=
current_user
.
expanded_groups_requiring_two_factor_authentication
.
reorder
(
name: :asc
)
...
...
@@ -36,7 +36,7 @@
end
def
two_factor_grace_period
periods
=
[
current_application_s
ettings
.
two_factor_grace_period
]
periods
=
[
Gitlab
::
CurrentS
ettings
.
two_factor_grace_period
]
periods
<<
current_user
.
two_factor_grace_period
if
current_user
.
try
(
:require_two_factor_authentication_from_group?
)
periods
.
min
end
...
...
app/controllers/concerns/requires_whitelisted_monitoring_client.rb
View file @
af2f9307
module
RequiresWhitelistedMonitoringClient
extend
ActiveSupport
::
Concern
include
Gitlab
::
CurrentSettings
included
do
before_action
:validate_ip_whitelisted_or_valid_token!
end
...
...
@@ -26,7 +24,7 @@
token
.
present?
&&
ActiveSupport
::
SecurityUtils
.
variable_size_secure_compare
(
token
,
current_application_s
ettings
.
health_check_access_token
Gitlab
::
CurrentS
ettings
.
health_check_access_token
)
end
...
...
app/controllers/invites_controller.rb
View file @
af2f9307
...
...
@@ -51,7 +51,7 @@
return
if
current_user
notice
=
"To accept this invitation, sign in"
notice
<<
" or create an account"
if
current_application_s
ettings
.
allow_signup?
notice
<<
" or create an account"
if
Gitlab
::
CurrentS
ettings
.
allow_signup?
notice
<<
"."
store_location_for
:user
,
request
.
fullpath
...
...
app/controllers/koding_controller.rb
View file @
af2f9307
...
...
@@ -10,6 +10,6 @@
private
def
check_integration!
render_404
unless
current_application_s
ettings
.
koding_enabled?
render_404
unless
Gitlab
::
CurrentS
ettings
.
koding_enabled?
end
end
app/controllers/oauth/applications_controller.rb
View file @
af2f9307
class
Oauth::ApplicationsController
<
Doorkeeper
::
ApplicationsController
include
Gitlab
::
CurrentSettings
include
Gitlab
::
GonHelper
include
PageLayoutHelper
include
OauthApplications
...
...
@@ -31,7 +30,7 @@
private
def
verify_user_oauth_applications_enabled
return
if
current_application_s
ettings
.
user_oauth_applications?
return
if
Gitlab
::
CurrentS
ettings
.
user_oauth_applications?
redirect_to
profile_path
end
...
...
app/controllers/omniauth_callbacks_controller.rb
View file @
af2f9307
...
...
@@ -145,7 +145,7 @@
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_s
ettings
.
allow_signup?
if
Gitlab
::
CurrentS
ettings
.
allow_signup?
message
<<
" Create a GitLab account first, and then connect it to your
#{
label
}
account."
end
...
...
app/controllers/passwords_controller.rb
View file @
af2f9307
class
PasswordsController
<
Devise
::
PasswordsController
include
Gitlab
::
CurrentSettings
skip_before_action
:require_no_authentication
,
only:
[
:edit
,
:update
]
before_action
:resource_from_email
,
only:
[
:create
]
...
...
@@ -46,7 +44,7 @@
if
resource
return
if
resource
.
allow_password_authentication?
else
return
if
current_application_s
ettings
.
password_authentication_enabled?
return
if
Gitlab
::
CurrentS
ettings
.
password_authentication_enabled?
end
redirect_to
after_sending_reset_password_instructions_path_for
(
resource_name
),
...
...
app/controllers/projects_controller.rb
View file @
af2f9307
...
...
@@ -394,7 +394,7 @@
end
def
project_export_enabled
render_404
unless
current_application_s
ettings
.
project_export_enabled?
render_404
unless
Gitlab
::
CurrentS
ettings
.
project_export_enabled?
end
def
redirect_git_extension
...
...
app/controllers/root_controller.rb
View file @
af2f9307
...
...
@@ -23,7 +23,7 @@
def
redirect_unlogged_user
if
redirect_to_home_page_url?
redirect_to
(
current_application_s
ettings
.
home_page_url
)
redirect_to
(
Gitlab
::
CurrentS
ettings
.
home_page_url
)
else
redirect_to
(
new_user_session_path
)
end
...
...
@@ -48,5 +48,5 @@
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_s
ettings
.
home_page_url
.
present?
return
false
unless
Gitlab
::
CurrentS
ettings
.
home_page_url
.
present?
...
...
@@ -52,5 +52,5 @@
home_page_url
=
current_application_s
ettings
.
home_page_url
.
chomp
(
'/'
)
home_page_url
=
Gitlab
::
CurrentS
ettings
.
home_page_url
.
chomp
(
'/'
)
root_urls
=
[
Gitlab
.
config
.
gitlab
[
'url'
].
chomp
(
'/'
),
root_url
.
chomp
(
'/'
)]
root_urls
.
exclude?
(
home_page_url
)
...
...
app/helpers/application_settings_helper.rb
View file @
af2f9307
module
ApplicationSettingsHelper
extend
self
include
Gitlab
::
CurrentSettings
delegate
:allow_signup?
,
:gravatar_enabled?
,
:password_authentication_enabled_for_web?
,
:akismet_enabled?
,
:koding_enabled?
,
...
...
@@ -6,8 +4,8 @@
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?
...
...
@@ -12,6 +10,6 @@
def
user_oauth_applications?
current_application_s
ettings
.
user_oauth_applications
Gitlab
::
CurrentS
ettings
.
user_oauth_applications
end
def
allowed_protocols_present?
...
...
@@ -15,7 +13,7 @@
end
def
allowed_protocols_present?
current_application_s
ettings
.
enabled_git_access_protocol
.
present?
Gitlab
::
CurrentS
ettings
.
enabled_git_access_protocol
.
present?
end
def
enabled_protocol
...
...
@@ -19,7 +17,7 @@
end
def
enabled_protocol
case
current_application_s
ettings
.
enabled_git_access_protocol
case
Gitlab
::
CurrentS
ettings
.
enabled_git_access_protocol
when
'http'
gitlab_config
.
protocol
when
'ssh'
...
...
@@ -57,7 +55,7 @@
# toggle button effect.
def
import_sources_checkboxes
(
help_block_id
)
Gitlab
::
ImportSources
.
options
.
map
do
|
name
,
source
|
checked
=
current_application_s
ettings
.
import_sources
.
include?
(
source
)
checked
=
Gitlab
::
CurrentS
ettings
.
import_sources
.
include?
(
source
)
css_class
=
checked
?
'active'
:
''
checkbox_name
=
'application_setting[import_sources][]'
...
...
@@ -72,7 +70,7 @@
def
oauth_providers_checkboxes
button_based_providers
.
map
do
|
source
|
disabled
=
current_application_s
ettings
.
disabled_oauth_sign_in_sources
.
include?
(
source
.
to_s
)
disabled
=
Gitlab
::
CurrentS
ettings
.
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][]'
...
...
app/helpers/auth_helper.rb
View file @
af2f9307
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
...
...
@@ -41,7 +39,7 @@
end
def
enabled_button_based_providers
disabled_providers
=
current_application_s
ettings
.
disabled_oauth_sign_in_sources
||
[]
disabled_providers
=
Gitlab
::
CurrentS
ettings
.
disabled_oauth_sign_in_sources
||
[]
button_based_providers
.
map
(
&
:to_s
)
-
disabled_providers
end
...
...
app/helpers/projects_helper.rb
View file @
af2f9307
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'
)
...
...
@@ -214,7 +212,7 @@
project
.
cache_key
,
controller
.
controller_name
,
controller
.
action_name
,
current_application_s
ettings
.
cache_key
,
Gitlab
::
CurrentS
ettings
.
cache_key
,
'v2.5'
]
...
...
@@ -447,6 +445,6 @@
path
=
"
#{
import_path
}
?repo=
#{
repo
}
&branch=
#{
branch
}
&sha=
#{
sha
}
"
return
URI
.
join
(
current_application_s
ettings
.
koding_url
,
path
).
to_s
return
URI
.
join
(
Gitlab
::
CurrentS
ettings
.
koding_url
,
path
).
to_s
end
...
...
@@ -451,6 +449,6 @@
end
current_application_s
ettings
.
koding_url
Gitlab
::
CurrentS
ettings
.
koding_url
end
def
contribution_guide_path
(
project
)
...
...
@@ -559,7 +557,7 @@
def
restricted_levels
return
[]
if
current_user
.
admin?
current_application_s
ettings
.
restricted_visibility_levels
||
[]
Gitlab
::
CurrentS
ettings
.
restricted_visibility_levels
||
[]
end
def
project_permissions_settings
(
project
)
...
...
app/helpers/version_check_helper.rb
View file @
af2f9307
module
VersionCheckHelper
def
version_status_badge
if
Rails
.
env
.
production?
&&
current_application_s
ettings
.
version_check_enabled
if
Rails
.
env
.
production?
&&
Gitlab
::
CurrentS
ettings
.
version_check_enabled
image_url
=
VersionCheck
.
new
.
url
image_tag
image_url
,
class:
'js-version-status-badge'
end
...
...
app/helpers/visibility_level_helper.rb
View file @
af2f9307
...
...
@@ -151,8 +151,8 @@
def
restricted_visibility_levels
(
show_all
=
false
)
return
[]
if
current_user
.
admin?
&&
!
show_all
current_application_s
ettings
.
restricted_visibility_levels
||
[]
Gitlab
::
CurrentS
ettings
.
restricted_visibility_levels
||
[]
end
delegate
:default_project_visibility
,
:default_group_visibility
,
...
...
@@ -155,8 +155,8 @@
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?
)
...
...
app/mailers/abuse_report_mailer.rb
View file @
af2f9307
class
AbuseReportMailer
<
BaseMailer
include
Gitlab
::
CurrentSettings
def
notify
(
abuse_report_id
)
return
unless
deliverable?
@abuse_report
=
AbuseReport
.
find
(
abuse_report_id
)
mail
(
...
...
@@ -4,10 +2,10 @@
def
notify
(
abuse_report_id
)
return
unless
deliverable?
@abuse_report
=
AbuseReport
.
find
(
abuse_report_id
)
mail
(
to:
current_application_s
ettings
.
admin_notification_email
,
to:
Gitlab
::
CurrentS
ettings
.
admin_notification_email
,
subject:
"
#{
@abuse_report
.
user
.
name
}
(
#{
@abuse_report
.
user
.
username
}
) was reported for abuse"
)
end
...
...
@@ -15,6 +13,6 @@
private
def
deliverable?
current_application_s
ettings
.
admin_notification_email
.
present?
Gitlab
::
CurrentS
ettings
.
admin_notification_email
.
present?
end
end
app/mailers/base_mailer.rb
View file @
af2f9307
class
BaseMailer
<
ActionMailer
::
Base
include
Gitlab
::
CurrentSettings
around_action
:render_with_default_locale
helper
ApplicationHelper
helper
MarkupHelper
attr_accessor
:current_user
...
...
@@ -4,10 +2,10 @@
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
}
...
...
app/models/clusters/platforms/kubernetes.rb
View file @
af2f9307
module
Clusters
module
Platforms
class
Kubernetes
<
ActiveRecord
::
Base
include
Gitlab
::
CurrentSettings
include
Gitlab
::
Kubernetes
include
ReactiveCaching
...
...
@@ -169,7 +168,7 @@
{
token:
token
,
ca_pem:
ca_pem
,
max_session_time:
current_application_s
ettings
.
terminal_max_session_time
max_session_time:
Gitlab
::
CurrentS
ettings
.
terminal_max_session_time
}
end
...
...
app/models/issue_assignee.rb
View file @
af2f9307
class
IssueAssignee
<
ActiveRecord
::
Base
extend
Gitlab
::
CurrentSettings
belongs_to
:issue
belongs_to
:assignee
,
class_name:
"User"
,
foreign_key: :user_id
end
Prev
1
2
3
4
5
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment