Sha256: d3df0350211bc31056359ef2c2f12264cff0cdd8861b31f9e5249dccfce97939

Contents?: true

Size: 615 Bytes

Versions: 53

Compression:

Stored size: 615 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # Store user's social identities
  class Identity < ApplicationRecord
    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

    private

    def same_organization
      return if organization == user&.organization
      errors.add(:organization, :invalid)
    end
  end
end

Version data entries

53 entries across 53 versions & 2 rubygems

Version Path
decidim-0.6.0 decidim-core/app/models/decidim/identity.rb
decidim-core-0.5.1 app/models/decidim/identity.rb
decidim-0.5.1 decidim-core/app/models/decidim/identity.rb
decidim-core-0.5.0 app/models/decidim/identity.rb
decidim-0.5.0 decidim-core/app/models/decidim/identity.rb
decidim-core-0.4.4 app/models/decidim/identity.rb
decidim-core-0.4.2 app/models/decidim/identity.rb
decidim-core-0.4.1 app/models/decidim/identity.rb
decidim-core-0.4.3 app/models/decidim/identity.rb
decidim-core-0.4.0 app/models/decidim/identity.rb
decidim-core-0.3.2 app/models/decidim/identity.rb
decidim-core-0.3.1 app/models/decidim/identity.rb
decidim-core-0.3.0 app/models/decidim/identity.rb