summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2018-02-15 09:27:38 +0000
committerDouwe Maan <douwe@gitlab.com>2018-02-15 09:27:38 +0000
commit26af0e2d601401114a0574203a56f5f71417adf3 (patch)
tree71c316455f3e11444b5d24b5ccee302c81cde238 /app
parent16ca6914f622ce7ddf116173293c6f49a93092bc (diff)
downloadgitlab-ce-26af0e2d601401114a0574203a56f5f71417adf3.tar.gz
Fixed user synced attributes metadata after removing current provider
Diffstat (limited to 'app')
-rw-r--r--app/models/identity.rb9
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