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
6b89de85
Commit
6b89de85
authored
Dec 02, 2021
by
Igor Drozdov
Committed by
GitLab Release Tools Bot
Dec 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scope available templates to current user
parent
20cb1800
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
2 deletions
+58
-2
ee/app/controllers/ee/users_controller.rb
ee/app/controllers/ee/users_controller.rb
+10
-2
ee/spec/controllers/users_controller_spec.rb
ee/spec/controllers/users_controller_spec.rb
+48
-0
No files found.
ee/app/controllers/ee/users_controller.rb
View file @
6b89de85
...
...
@@ -29,12 +29,20 @@ module EE
super
.
with_compliance_framework_settings
end
# Even though available templates endpoints accept a user
# We don't allow fetching the templates for arbitrary user
# The endpoints are going to be removed in
# https://gitlab.com/gitlab-org/gitlab/-/issues/345897
def
load_custom_project_templates
@custom_project_templates
||=
user
.
available_custom_project_templates
(
search:
params
[
:search
]).
page
(
params
[
:page
])
render_404
unless
user
==
current_user
@custom_project_templates
||=
user
.
available_custom_project_templates
(
search:
params
[
:search
]).
page
(
params
[
:page
])
# rubocop:disable Gitlab/ModuleWithInstanceVariables
end
def
load_group_project_templates
@groups_with_project_templates
||=
render_404
unless
user
==
current_user
@groups_with_project_templates
||=
# rubocop:disable Gitlab/ModuleWithInstanceVariables
user
.
available_subgroups_with_custom_project_templates
(
params
[
:group_id
])
.
page
(
params
[
:page
])
end
...
...
ee/spec/controllers/users_controller_spec.rb
0 → 100644
View file @
6b89de85
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
UsersController
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:another_user
)
{
create
(
:user
)
}
before
do
sign_in
(
user
)
end
describe
'GET #available_project_templates'
do
context
'a user requests templates for themselves'
do
it
'responds successfully'
do
get
:available_project_templates
,
params:
{
username:
user
.
username
},
xhr:
true
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
context
'a user requests templates for another user'
do
it
'responds with not found error'
do
get
:available_project_templates
,
params:
{
username:
another_user
.
username
},
xhr:
true
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
describe
'GET #available_group_templates'
do
context
'a user requests templates for themselves'
do
it
'responds successfully'
do
get
:available_group_templates
,
params:
{
username:
user
.
username
},
xhr:
true
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
context
'a user requests templates for another user'
do
it
'responds with not found error'
do
get
:available_group_templates
,
params:
{
username:
another_user
.
username
},
xhr:
true
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
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