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
b221d11a
Commit
b221d11a
authored
Feb 25, 2016
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to delete a user with force
parent
4bcc0977
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
18 deletions
+22
-18
CHANGELOG
CHANGELOG
+1
-1
app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
+1
-1
app/models/abuse_report.rb
app/models/abuse_report.rb
+2
-2
app/services/delete_user_service.rb
app/services/delete_user_service.rb
+14
-10
app/services/destroy_group_service.rb
app/services/destroy_group_service.rb
+2
-2
app/workers/delete_user_worker.rb
app/workers/delete_user_worker.rb
+2
-2
No files found.
CHANGELOG
View file @
b221d11a
...
@@ -59,6 +59,7 @@ v 8.5.3
...
@@ -59,6 +59,7 @@ v 8.5.3
- Show commit message in JIRA mention comment
- Show commit message in JIRA mention comment
- Makes issue page and merge request page usable on mobile browsers.
- Makes issue page and merge request page usable on mobile browsers.
- Improved UI for profile settings
- Improved UI for profile settings
- User deletion is now done in the background so the request can not time out
v 8.5.2
v 8.5.2
- Fix sidebar overlapping content when screen width was below 1200px
- Fix sidebar overlapping content when screen width was below 1200px
...
@@ -178,7 +179,6 @@ v 8.5.0
...
@@ -178,7 +179,6 @@ v 8.5.0
v 8.4.5
v 8.4.5
- No CE-specific changes
- No CE-specific changes
- User deletion is now done in the background so the request can not time out
v 8.4.4
v 8.4.4
- Update omniauth-saml gem to 1.4.2
- Update omniauth-saml gem to 1.4.2
...
...
app/controllers/admin/users_controller.rb
View file @
b221d11a
...
@@ -119,7 +119,7 @@ class Admin::UsersController < Admin::ApplicationController
...
@@ -119,7 +119,7 @@ class Admin::UsersController < Admin::ApplicationController
end
end
def
destroy
def
destroy
DeleteUser
Service
.
new
(
current_user
).
execute
(
user
)
DeleteUser
Worker
.
perform_async
(
current_user
.
id
,
user
.
id
)
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
{
redirect_to
admin_users_path
,
notice:
"The user is being deleted."
}
format
.
html
{
redirect_to
admin_users_path
,
notice:
"The user is being deleted."
}
...
...
app/models/abuse_report.rb
View file @
b221d11a
...
@@ -19,9 +19,9 @@ class AbuseReport < ActiveRecord::Base
...
@@ -19,9 +19,9 @@ class AbuseReport < ActiveRecord::Base
validates
:message
,
presence:
true
validates
:message
,
presence:
true
validates
:user_id
,
uniqueness:
{
message:
'has already been reported'
}
validates
:user_id
,
uniqueness:
{
message:
'has already been reported'
}
def
remove_user
def
remove_user
(
current_user
)
user
.
block
user
.
block
user
.
destroy
DeleteUserWorker
.
perform_async
(
current_user
.
id
,
user
.
id
,
force:
true
)
end
end
def
notify
def
notify
...
...
app/services/delete_user_service.rb
View file @
b221d11a
...
@@ -5,18 +5,22 @@ class DeleteUserService
...
@@ -5,18 +5,22 @@ class DeleteUserService
@current_user
=
current_user
@current_user
=
current_user
end
end
def
execute
(
user
)
def
execute
(
user
,
options
=
{}
)
if
user
.
solo_owned_groups
.
present?
if
!
options
[
:force
]
&&
user
.
solo_owned_groups
.
present?
user
.
errors
[
:base
]
<<
'You must transfer ownership or delete groups before you can remove user'
user
.
errors
[
:base
]
<<
'You must transfer ownership or delete groups before you can remove user'
user
return
user
else
end
user
.
personal_projects
.
each
do
|
project
|
# Skip repository removal because we remove directory with namespace
user
.
solo_owned_groups
.
each
do
|
group
|
# that contain all this repositories
DeleteGroupService
.
new
(
group
,
current_user
).
execute
::
Projects
::
DestroyService
.
new
(
project
,
current_user
,
skip_repo:
true
).
pending_delete!
end
end
user
.
destroy
user
.
personal_projects
.
each
do
|
project
|
# Skip repository removal because we remove directory with namespace
# that contain all this repositories
::
Projects
::
DestroyService
.
new
(
project
,
current_user
,
skip_repo:
true
).
pending_delete!
end
end
user
.
destroy
end
end
end
end
app/services/destroy_group_service.rb
View file @
b221d11a
...
@@ -6,12 +6,12 @@ class DestroyGroupService
...
@@ -6,12 +6,12 @@ class DestroyGroupService
end
end
def
execute
def
execute
@
group
.
projects
.
each
do
|
project
|
group
.
projects
.
each
do
|
project
|
# Skip repository removal because we remove directory with namespace
# Skip repository removal because we remove directory with namespace
# that contain all this repositories
# that contain all this repositories
::
Projects
::
DestroyService
.
new
(
project
,
current_user
,
skip_repo:
true
).
pending_delete!
::
Projects
::
DestroyService
.
new
(
project
,
current_user
,
skip_repo:
true
).
pending_delete!
end
end
@
group
.
destroy
group
.
destroy
end
end
end
end
app/workers/delete_user_worker.rb
View file @
b221d11a
class
DeleteUserWorker
class
DeleteUserWorker
include
Sidekiq
::
Worker
include
Sidekiq
::
Worker
def
perform
(
current_user_id
,
delete_user_id
)
def
perform
(
current_user_id
,
delete_user_id
,
options
=
{}
)
delete_user
=
User
.
find
(
delete_user_id
)
delete_user
=
User
.
find
(
delete_user_id
)
current_user
=
User
.
find
(
current_user_id
)
current_user
=
User
.
find
(
current_user_id
)
DeleteUserService
.
new
(
current_user
).
execute
(
delete_user
)
DeleteUserService
.
new
(
current_user
).
execute
(
delete_user
,
options
.
symbolize_keys
)
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