Sha256: 2c8fb93dec55f3103a18292abc01c64281d078397cfb2db69d839a17697d17af
Contents?: true
Size: 995 Bytes
Versions: 1
Compression:
Stored size: 995 Bytes
Contents
# frozen_string_literal: true module DeviseTokenAuth::Concerns::UserOmniauthCallbacks extend ActiveSupport::Concern included do validates self.authentication_keys.first, presence: true,if: :email_provider? if self.authentication_keys.first == :email validates self.authentication_keys.first, :devise_token_auth_email => true, allow_nil: true, allow_blank: true, if: :email_provider? end validates_presence_of :uid, unless: :email_provider? # only validate unique emails among email registration users validates self.authentication_keys.first, uniqueness: { case_sensitive: false, scope: [ :provider ] + DeviseTokenAuth.multitenancy_scope_fields }, on: :create, if: :email_provider? # keep uid in sync with email before_save :sync_uid before_create :sync_uid end protected def email_provider? provider == 'email' end def sync_uid self.uid = self.send(self.class.authentication_keys.first.to_sym) if email_provider? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
devise_token_auth_multitenancy-1.1.3.2 | app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb |