Class: TwoFactor::DestroyService

Inherits:
BaseService show all
Defined in:
app/services/two_factor/destroy_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #group, #user

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

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

This class inherits a constructor from TwoFactor::BaseService

Instance Method Details

#executeObject



5
6
7
8
9
10
11
12
13
14
# File 'app/services/two_factor/destroy_service.rb', line 5

def execute
  return error(_('You are not authorized to perform this action')) unless authorized?
  return error(_('Two-factor authentication is not enabled for this user')) unless user.two_factor_enabled?

  result = disable_two_factor

  notify_on_success(user) if result[:status] == :success

  result
end