Backport Identity.uniqueness_scope from EE
Originates in 'SamlProvider has many linked Identities' from EE
This commit is contained in:
parent
b51f6e2c21
commit
d14851f9a3
1 changed files with 6 additions and 2 deletions
|
@ -1,12 +1,16 @@
|
|||
class Identity < ActiveRecord::Base
|
||||
def self.uniqueness_scope
|
||||
:provider
|
||||
end
|
||||
|
||||
include Sortable
|
||||
include CaseSensitivity
|
||||
|
||||
belongs_to :user
|
||||
|
||||
validates :provider, presence: true
|
||||
validates :extern_uid, allow_blank: true, uniqueness: { scope: :provider, case_sensitive: false }
|
||||
validates :user_id, uniqueness: { scope: :provider }
|
||||
validates :extern_uid, allow_blank: true, uniqueness: { scope: uniqueness_scope, case_sensitive: false }
|
||||
validates :user_id, uniqueness: { scope: uniqueness_scope }
|
||||
|
||||
before_save :ensure_normalized_extern_uid, if: :extern_uid_changed?
|
||||
after_destroy :clear_user_synced_attributes, if: :user_synced_attributes_metadata_from_provider?
|
||||
|
|
Loading…
Reference in a new issue