Module: Identity::Mixins::User

Defined in:
lib/identity/mixins/user.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/identity/mixins/user.rb', line 4

def self.included(base)
  base.devise *Identity.devise_modules
  base.extend ClassMethods

  if Devise.omniauth_providers.any?
    base.devise :omniauthable, omniauth_providers: Devise.omniauth_providers
  end
end

Instance Method Details

#build_from_auth(auth) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/identity/mixins/user.rb', line 13

def build_from_auth(auth)
  auth_provider = auth.provider.gsub(/\_/, '-')
  self.email = "#{auth.uid}@#{auth_provider}.com"
  self.password = Devise.friendly_token[0,20]
  self.oauth_hash = auth

  send("build_from_#{auth.provider}", auth) if respond_to?("build_from_#{auth.provider}")
end