Welcome to mirror list, hosted at ThFree Co, Russian Federation.

user_synced_attributes_metadata.rb « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9f37430416401a5d7d0e5651957ed822d8815fbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class UserSyncedAttributesMetadata < ActiveRecord::Base
  belongs_to :user

  validates :user, presence: true

  SYNCABLE_ATTRIBUTES = %i[name email location].freeze

  def read_only?(attribute)
    Gitlab.config.omniauth.sync_profile_from_provider && synced?(attribute)
  end

  def read_only_attributes
    return [] unless Gitlab.config.omniauth.sync_profile_from_provider

    SYNCABLE_ATTRIBUTES.select { |key| synced?(key) }
  end

  def synced?(attribute)
    read_attribute("#{attribute}_synced")
  end

  def set_attribute_synced(attribute, value)
    write_attribute("#{attribute}_synced", value)
  end
end