Class: Webauthn::DestroyService

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

Instance Attribute Summary collapse

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, user, webauthn_registrations_id) ⇒ DestroyService

Returns a new instance of DestroyService.



7
8
9
10
11
# File 'app/services/webauthn/destroy_service.rb', line 7

def initialize(current_user, user, webauthn_registrations_id)
  @current_user = current_user
  @user = user
  @webauthn_registration = user.webauthn_registrations.find(webauthn_registrations_id)
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



5
6
7
# File 'app/services/webauthn/destroy_service.rb', line 5

def current_user
  @current_user
end

#userObject (readonly)

Returns the value of attribute user.



5
6
7
# File 'app/services/webauthn/destroy_service.rb', line 5

def user
  @user
end

#webauthn_registrationObject (readonly)

Returns the value of attribute webauthn_registration.



5
6
7
# File 'app/services/webauthn/destroy_service.rb', line 5

def webauthn_registration
  @webauthn_registration
end

Instance Method Details

#executeObject



13
14
15
16
17
18
# File 'app/services/webauthn/destroy_service.rb', line 13

def execute
  return error(_('You are not authorized to perform this action')) unless authorized?

  webauthn_registration.destroy
  user.reset_backup_codes! if last_two_factor_registration?
end