diff options
author | Mark Fletcher <markglenfletcher@googlemail.com> | 2018-02-19 15:36:21 +0300 |
---|---|---|
committer | Mark Fletcher <markglenfletcher@googlemail.com> | 2018-02-19 15:36:21 +0300 |
commit | 76f3921140e10e195db8271217b675402b679609 (patch) | |
tree | 512eb9fbd83d04c406861134c8eb99afc875fc58 /app/models/identity.rb | |
parent | dcd1a43faf9654bf6e36d47d88dc914a100c4e33 (diff) | |
parent | 27a6d876cb690526713baea49ceea2d6dde75417 (diff) |
Merge branch '10-5-stable-prepare-rc9' into '10-5-stable'
Prepare 10.5 RC9 release
See merge request gitlab-org/gitlab-ce!17210
Diffstat (limited to 'app/models/identity.rb')
-rw-r--r-- | app/models/identity.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/identity.rb b/app/models/identity.rb index b3fa7d8176a..2b433e9b988 100644 --- a/app/models/identity.rb +++ b/app/models/identity.rb @@ -9,6 +9,7 @@ class Identity < ActiveRecord::Base validates :user_id, uniqueness: { scope: :provider } before_save :ensure_normalized_extern_uid, if: :extern_uid_changed? + after_destroy :clear_user_synced_attributes, if: :user_synced_attributes_metadata_from_provider? scope :with_provider, ->(provider) { where(provider: provider) } scope :with_extern_uid, ->(provider, extern_uid) do @@ -34,4 +35,12 @@ class Identity < ActiveRecord::Base self.extern_uid = Identity.normalize_uid(self.provider, self.extern_uid) end + + def user_synced_attributes_metadata_from_provider? + user.user_synced_attributes_metadata&.provider == provider + end + + def clear_user_synced_attributes + user.user_synced_attributes_metadata&.destroy + end end |