Class: Users::BannedUserBaseService

Inherits:
BaseService show all
Defined in:
app/services/users/banned_user_base_service.rb

Direct Known Subclasses

BanService, UnbanService

Instance Attribute Summary

Attributes inherited from BaseService

#params, #project

Instance Method Summary collapse

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(current_user) ⇒ BannedUserBaseService

Returns a new instance of BannedUserBaseService.


5
6
7
# File 'app/services/users/banned_user_base_service.rb', line 5

def initialize(current_user)
  @current_user = current_user
end

Instance Method Details

#execute(user) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/services/users/banned_user_base_service.rb', line 9

def execute(user)
  return permission_error unless allowed?
  return state_error(user) unless valid_state?(user)

  if update_user(user)
    log_event(user)
    success
  else
    messages = user.errors.full_messages
    error(messages.uniq.join('. '))
  end
end