remove_linked_account.rb 594 B

1234567891011121314151617181920212223
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Service::User::RemoveLinkedAccount < Service::Base
  3. attr_reader :provider, :uid, :current_user
  4. def initialize(provider:, uid:, current_user:)
  5. super()
  6. @provider = provider
  7. @uid = uid
  8. @current_user = current_user
  9. end
  10. def execute
  11. records = Authorization.where(
  12. user_id: @current_user.id,
  13. provider: @provider,
  14. uid: @uid,
  15. ).destroy_all
  16. raise Exceptions::UnprocessableEntity, __('The linked account could not be found.') if records.count.zero?
  17. end
  18. end