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
b248ee93
Commit
b248ee93
authored
Apr 05, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check permissions when importing project members
Closes #14899
parent
8a0a802e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
2 deletions
+59
-2
CHANGELOG
CHANGELOG
+3
-0
app/controllers/projects/project_members_controller.rb
app/controllers/projects/project_members_controller.rb
+7
-2
spec/controllers/projects/project_members_controller_spec.rb
spec/controllers/projects/project_members_controller_spec.rb
+49
-0
No files found.
CHANGELOG
View file @
b248ee93
...
@@ -20,6 +20,9 @@ v 8.7.0 (unreleased)
...
@@ -20,6 +20,9 @@ v 8.7.0 (unreleased)
- Fall back to `In-Reply-To` and `References` headers when sub-addressing is not available (David Padilla)
- Fall back to `In-Reply-To` and `References` headers when sub-addressing is not available (David Padilla)
- Remove "Congratulations!" tweet button on newly-created project. (Connor Shea)
- Remove "Congratulations!" tweet button on newly-created project. (Connor Shea)
v 8.6.5 (unreleased)
- Check permissions when user attempts to import members from another project
v 8.6.4
v 8.6.4
- Don't attempt to fetch any tags from a forked repo (Stan Hu)
- Don't attempt to fetch any tags from a forked repo (Stan Hu)
...
...
app/controllers/projects/project_members_controller.rb
View file @
b248ee93
...
@@ -95,8 +95,13 @@ class Projects::ProjectMembersController < Projects::ApplicationController
...
@@ -95,8 +95,13 @@ class Projects::ProjectMembersController < Projects::ApplicationController
def
apply_import
def
apply_import
giver
=
Project
.
find
(
params
[
:source_project_id
])
giver
=
Project
.
find
(
params
[
:source_project_id
])
if
current_user
.
can?
(
:read_project_member
,
giver
)
status
=
@project
.
team
.
import
(
giver
,
current_user
)
status
=
@project
.
team
.
import
(
giver
,
current_user
)
notice
=
status
?
"Successfully imported"
:
"Import failed"
notice
=
status
?
"Successfully imported"
:
"Import failed"
else
notice
=
'You are not authorized to import members from this project'
end
redirect_to
(
namespace_project_project_members_path
(
project
.
namespace
,
project
),
redirect_to
(
namespace_project_project_members_path
(
project
.
namespace
,
project
),
notice:
notice
)
notice:
notice
)
...
...
spec/controllers/projects/project_members_controller_spec.rb
0 → 100644
View file @
b248ee93
require
(
'spec_helper'
)
describe
Projects
::
ProjectMembersController
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:another_project
)
{
create
(
:project
,
:private
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:member
)
{
create
(
:user
)
}
before
do
project
.
team
<<
[
user
,
:master
]
another_project
.
team
<<
[
member
,
:guest
]
sign_in
(
user
)
end
describe
'#apply_import'
do
shared_context
'import applied'
do
before
do
post
(
:apply_import
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
source_project_id:
another_project
.
id
)
end
end
context
'when user can access source project members'
do
before
{
another_project
.
team
<<
[
user
,
:guest
]
}
include_context
'import applied'
it
'imports source project members'
do
expect
(
project
.
team_members
).
to
include
member
expect
(
response
).
to
set_flash
.
to
'Successfully imported'
expect
(
response
).
to
redirect_to
(
namespace_project_project_members_path
(
project
.
namespace
,
project
)
)
end
end
context
'when user is not member of a source project'
do
include_context
'import applied'
it
'does not import team members'
do
expect
(
project
.
team_members
).
to_not
include
member
end
it
'notifies about invalid permissions'
do
expect
(
response
).
to
set_flash
.
to
/not authorized/
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