Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5dd35c17
Commit
5dd35c17
authored
Sep 13, 2019
by
Aakriti Gupta
Committed by
Douglas Barbosa Alexandre
Sep 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-factor auth related before_actions into parent controller
parent
767b5d77
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
23 deletions
+27
-23
ee/app/controllers/analytics/application_controller.rb
ee/app/controllers/analytics/application_controller.rb
+21
-0
ee/app/controllers/analytics/productivity_analytics_controller.rb
...ontrollers/analytics/productivity_analytics_controller.rb
+6
-23
No files found.
ee/app/controllers/analytics/application_controller.rb
View file @
5dd35c17
...
...
@@ -15,5 +15,26 @@ class Analytics::ApplicationController < ApplicationController
before_action
(
*
args
)
{
counter_klass
.
count
(
counter
)
}
end
def
authorize_view_productivity_analytics!
(
action
)
return
render_403
unless
can?
(
current_user
,
action
,
@group
||
:global
)
end
def
check_feature_availability!
(
feature
)
return
render_403
unless
::
License
.
feature_available?
(
feature
)
return
render_403
if
@group
&&
!
@group
.
root_ancestor
.
feature_available?
(
feature
)
end
def
load_group
return
unless
params
[
'group_id'
]
@group
=
find_routable!
(
Group
,
params
[
'group_id'
])
end
def
load_project
return
unless
@group
&&
params
[
'project_id'
]
@project
=
find_routable!
(
@group
.
projects
,
params
[
'project_id'
])
end
private_class_method
:check_feature_flag
,
:increment_usage_counter
end
ee/app/controllers/analytics/productivity_analytics_controller.rb
View file @
5dd35c17
...
...
@@ -7,8 +7,12 @@ class Analytics::ProductivityAnalyticsController < Analytics::ApplicationControl
before_action
:load_group
before_action
:load_project
before_action
:check_feature_availability!
before_action
:authorize_view_productivity_analytics!
before_action
->
{
check_feature_availability!
(
:productivity_analytics
)
}
before_action
->
{
authorize_view_productivity_analytics!
(
:view_productivity_analytics
)
}
include
IssuableCollections
...
...
@@ -47,27 +51,6 @@ class Analytics::ProductivityAnalyticsController < Analytics::ApplicationControl
end
end
def
authorize_view_productivity_analytics!
return
render_403
unless
can?
(
current_user
,
:view_productivity_analytics
,
@group
||
:global
)
end
def
check_feature_availability!
return
render_403
unless
::
License
.
feature_available?
(
:productivity_analytics
)
return
render_403
if
@group
&&
!
@group
.
root_ancestor
.
feature_available?
(
:productivity_analytics
)
end
def
load_group
return
unless
params
[
'group_id'
]
@group
=
find_routable!
(
Group
,
params
[
'group_id'
])
end
def
load_project
return
unless
@group
&&
params
[
'project_id'
]
@project
=
find_routable!
(
@group
.
projects
,
params
[
'project_id'
])
end
def
serializer
@serializer
||=
BaseSerializer
.
new
(
current_user:
current_user
)
end
...
...
Write
Preview
Markdown
is supported
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