Sha256: b8bffa6cda156f0bfb05e2438e732866880f45c50e7ea75e7316de1347898f9d
Contents?: true
Size: 852 Bytes
Versions: 17
Compression:
Stored size: 852 Bytes
Contents
# frozen_string_literal: true module Decidim # Store user's social identities class Identity < ApplicationRecord include Decidim::DataPortability 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::DataPortabilitySerializers::DataPortabilityIdentitySerializer end private def same_organization return if organization == user&.organization errors.add(:organization, :invalid) end end end
Version data entries
17 entries across 17 versions & 1 rubygems