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-core-0.12.2 app/models/decidim/identity.rb
decidim-core-0.12.1 app/models/decidim/identity.rb
decidim-core-0.12.0 app/models/decidim/identity.rb
decidim-core-0.11.2 app/models/decidim/identity.rb
decidim-core-0.12.0.pre app/models/decidim/identity.rb
decidim-core-0.11.1 app/models/decidim/identity.rb
decidim-core-0.11.0.pre1 app/models/decidim/identity.rb
decidim-core-0.10.1 app/models/decidim/identity.rb
decidim-core-0.10.0 app/models/decidim/identity.rb
decidim-core-0.9.3 app/models/decidim/identity.rb
decidim-core-0.9.2 app/models/decidim/identity.rb
decidim-core-0.9.1 app/models/decidim/identity.rb
decidim-core-0.9.0 app/models/decidim/identity.rb
decidim-core-0.8.4 app/models/decidim/identity.rb
decidim-core-0.8.3 app/models/decidim/identity.rb
decidim-core-0.8.2 app/models/decidim/identity.rb
decidim-core-0.8.1 app/models/decidim/identity.rb
decidim-core-0.8.0 app/models/decidim/identity.rb
decidim-core-0.7.4 app/models/decidim/identity.rb
decidim-core-0.7.3 app/models/decidim/identity.rb