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
71678a24
Commit
71678a24
authored
Mar 09, 2022
by
Ela Doğruyol
Committed by
Alex Pooley
Mar 09, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent user blocking themselves through API
parent
daae13af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
lib/api/users.rb
lib/api/users.rb
+2
-0
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+12
-0
No files found.
lib/api/users.rb
View file @
71678a24
...
...
@@ -702,6 +702,8 @@ module API
if
user
.
ldap_blocked?
forbidden!
(
'LDAP blocked users cannot be modified by the API'
)
elsif
current_user
==
user
forbidden!
(
'The API initiating user cannot be blocked by the API'
)
end
break
if
user
.
blocked?
...
...
spec/requests/api/users_spec.rb
View file @
71678a24
...
...
@@ -3116,6 +3116,18 @@ RSpec.describe API::Users do
expect
(
response
.
body
).
to
eq
(
'null'
)
end
end
context
'with the API initiating user'
do
let
(
:user_id
)
{
admin
.
id
}
it
'does not block the API initiating user, returns 403'
do
block_user
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
expect
(
json_response
[
'message'
]).
to
eq
(
'403 Forbidden - The API initiating user cannot be blocked by the API'
)
expect
(
admin
.
reload
.
state
).
to
eq
(
'active'
)
end
end
end
it
'is not available for non admin users'
do
...
...
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