Class: Users::ActivateService
- Inherits:
-
BaseService
- Object
- BaseService
- Users::ActivateService
- Defined in:
- app/services/users/activate_service.rb
Instance Attribute Summary
Attributes inherited from BaseService
Instance Method Summary collapse
- #execute(user) ⇒ Object
-
#initialize(current_user) ⇒ ActivateService
constructor
A new instance of ActivateService.
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
Constructor Details
#initialize(current_user) ⇒ ActivateService
Returns a new instance of ActivateService.
5 6 7 |
# File 'app/services/users/activate_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 21 22 23 |
# File 'app/services/users/activate_service.rb', line 9 def execute(user) return error(_('You are not authorized to perform this action'), :forbidden) unless allowed? return error(_('Error occurred. A blocked user must be unblocked to be activated'), :forbidden) if user.blocked? return success(_('Successfully activated')) if user.active? if user.activate after_activate_hook(user) log_event(user) success(_('Successfully activated')) else error(user.errors..to_sentence, :unprocessable_entity) end end |