Sha256: 9dbe71e0a932662ac89977c87596fcdde1b3add84478be971ee4ceaf1f0c442f

Contents?: true

Size: 742 Bytes

Versions: 1

Compression:

Stored size: 742 Bytes

Contents

module AccountDeletable
  extend ActiveSupport::Concern

  included do
    def soft_delete!
      ActiveRecord::Base.transaction do
        # raise error if user has any active subscription
        if try(:payment_subscriptions)&.active&.exists?
          raise StandardError, I18n.t('errors.user_deletion_error')
        end

        user_devices.destroy_all
        update_columns(
          deleted_at:           Time.zone.now,
          tokens:               nil,
          email:                nil,
          uid:                  SecureRandom.uuid,
          encrypted_password:   '',
          first_name:           nil,
          last_name:            nil,
          email_before_deleted: email
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pixelforce_kit-0.9 app/models/concerns/account_deletable.rb