Add read_instance_statistics global policy
This commit is contained in:
parent
1a611cf1e5
commit
21471777a0
4 changed files with 5 additions and 10 deletions
|
@ -4,11 +4,7 @@ class InstanceStatistics::ApplicationController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
layout 'instance_statistics'
|
layout 'instance_statistics'
|
||||||
|
|
||||||
def index
|
|
||||||
redirect_to instance_statistics_conversations_development_index_index_path
|
|
||||||
end
|
|
||||||
|
|
||||||
def authenticate_user!
|
def authenticate_user!
|
||||||
render_404 if ApplicationSettingsHelper.hide_instance_statistics?(current_user)
|
render_404 unless can?(current_user, :read_instance_statistics)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,10 +16,6 @@ module ApplicationSettingsHelper
|
||||||
Gitlab::CurrentSettings.enabled_git_access_protocol.present?
|
Gitlab::CurrentSettings.enabled_git_access_protocol.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def hide_instance_statistics?(user = current_user)
|
|
||||||
Gitlab::CurrentSettings.instance_statistics_visibility_private? && !user.admin?
|
|
||||||
end
|
|
||||||
|
|
||||||
def enabled_protocol
|
def enabled_protocol
|
||||||
case Gitlab::CurrentSettings.enabled_git_access_protocol
|
case Gitlab::CurrentSettings.enabled_git_access_protocol
|
||||||
when 'http'
|
when 'http'
|
||||||
|
|
|
@ -19,6 +19,9 @@ class GlobalPolicy < BasePolicy
|
||||||
@user&.required_terms_not_accepted?
|
@user&.required_terms_not_accepted?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
condition(:private_instance_statistics, score: 0) { Gitlab::CurrentSettings.instance_statistics_visibility_private? }
|
||||||
|
rule { admin | ~private_instance_statistics }.enable :read_instance_statistics
|
||||||
|
|
||||||
rule { anonymous }.policy do
|
rule { anonymous }.policy do
|
||||||
prevent :log_in
|
prevent :log_in
|
||||||
prevent :receive_notifications
|
prevent :receive_notifications
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
= nav_link(controller: 'admin/dashboard') do
|
= nav_link(controller: 'admin/dashboard') do
|
||||||
= link_to admin_root_path, class: 'admin-icon qa-admin-area-link', title: _('Admin area'), aria: { label: _("Admin area") }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
|
= link_to admin_root_path, class: 'admin-icon qa-admin-area-link', title: _('Admin area'), aria: { label: _("Admin area") }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
|
||||||
= sprite_icon('admin', size: 18)
|
= sprite_icon('admin', size: 18)
|
||||||
- unless hide_instance_statistics?
|
- if can?(current_user, :read_instance_statistics)
|
||||||
= nav_link(controller: :instance_statistics) do
|
= nav_link(controller: :instance_statistics) do
|
||||||
= link_to instance_statistics_root_path, title: 'Instance statistics', aria: { label: 'Instance statistics' }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
|
= link_to instance_statistics_root_path, title: 'Instance statistics', aria: { label: 'Instance statistics' }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
|
||||||
= sprite_icon('chart', size: 18)
|
= sprite_icon('chart', size: 18)
|
||||||
|
|
Loading…
Reference in a new issue