Sha256: 397dc86f31bbab2d27011a72f3b7d9c33954ddff8770a7a4f304f8d37872daa7

Contents?: true

Size: 856 Bytes

Versions: 25

Compression:

Stored size: 856 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # Store user's social identities
  class Identity < ApplicationRecord
    include Decidim::DownloadYourData

    belongs_to :user, foreign_key: :decidim_user_id, class_name: "Decidim::User"
    belongs_to :organization, foreign_key: :decidim_organization_id, class_name: "Decidim::Organization"

    validates :provider, presence: true
    validates :uid, presence: true, uniqueness: { scope: [:provider, :organization] }

    validate :same_organization

    def self.user_collection(user)
      where(decidim_user_id: user.id)
    end

    def self.export_serializer
      Decidim::DownloadYourDataSerializers::DownloadYourDataIdentitySerializer
    end

    private

    def same_organization
      return if organization == user&.organization

      errors.add(:organization, :invalid)
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/models/decidim/identity.rb
decidim-core-0.28.4 app/models/decidim/identity.rb
decidim-core-0.27.9 app/models/decidim/identity.rb
decidim-core-0.29.0 app/models/decidim/identity.rb
decidim-core-0.28.3 app/models/decidim/identity.rb
decidim-core-0.27.8 app/models/decidim/identity.rb
decidim-core-0.29.0.rc4 app/models/decidim/identity.rb
decidim-core-0.29.0.rc3 app/models/decidim/identity.rb
decidim-core-0.29.0.rc2 app/models/decidim/identity.rb
decidim-core-0.29.0.rc1 app/models/decidim/identity.rb
decidim-core-0.28.2 app/models/decidim/identity.rb
decidim-core-0.27.7 app/models/decidim/identity.rb
decidim-core-0.28.1 app/models/decidim/identity.rb
decidim-core-0.27.6 app/models/decidim/identity.rb
decidim-core-0.28.0 app/models/decidim/identity.rb
decidim-core-0.27.5 app/models/decidim/identity.rb
decidim-core-0.28.0.rc5 app/models/decidim/identity.rb
decidim-core-0.28.0.rc4 app/models/decidim/identity.rb
decidim-core-0.27.4 app/models/decidim/identity.rb
decidim-core-0.27.3 app/models/decidim/identity.rb