summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-26 09:11:15 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-26 09:11:15 +0000
commitc8a7e4ada117b968f841c2bb300fadc421cb3e98 (patch)
treec7c84dd22cd56ea8ed228f91f4ab33c5a1e751fc /app/services
parentb692f9afa047ef24c54ab185b499628d9873122a (diff)
downloadgitlab-ce-c8a7e4ada117b968f841c2bb300fadc421cb3e98.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r--app/services/users/ban_service.rb4
-rw-r--r--app/services/users/banned_user_base_service.rb5
-rw-r--r--app/services/users/unban_service.rb6
3 files changed, 14 insertions, 1 deletions
diff --git a/app/services/users/ban_service.rb b/app/services/users/ban_service.rb
index 88e92ebff9b..959d4be3795 100644
--- a/app/services/users/ban_service.rb
+++ b/app/services/users/ban_service.rb
@@ -8,6 +8,10 @@ module Users
user.ban
end
+ def valid_state?(user)
+ user.active?
+ end
+
def action
:ban
end
diff --git a/app/services/users/banned_user_base_service.rb b/app/services/users/banned_user_base_service.rb
index 16041075941..a582816283a 100644
--- a/app/services/users/banned_user_base_service.rb
+++ b/app/services/users/banned_user_base_service.rb
@@ -8,6 +8,7 @@ module Users
def execute(user)
return permission_error unless allowed?
+ return state_error(user) unless valid_state?(user)
if update_user(user)
log_event(user)
@@ -22,6 +23,10 @@ module Users
attr_reader :current_user
+ def state_error(user)
+ error(_("You cannot %{action} %{state} users." % { action: action.to_s, state: user.state }), :forbidden)
+ end
+
def allowed?
can?(current_user, :admin_all_resources)
end
diff --git a/app/services/users/unban_service.rb b/app/services/users/unban_service.rb
index 363783cf240..753a02fa752 100644
--- a/app/services/users/unban_service.rb
+++ b/app/services/users/unban_service.rb
@@ -5,7 +5,11 @@ module Users
private
def update_user(user)
- user.activate
+ user.unban
+ end
+
+ def valid_state?(user)
+ user.banned?
end
def action