Sha256: d46c31e7d7e2e7643d50acda1851e0fb2c3f26c5f97da060ae38251e6233b47a
Contents?: true
Size: 1.53 KB
Versions: 3
Compression:
Stored size: 1.53 KB
Contents
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable def self.find_for_oauth(auth, signed_in_resource = nil) # Get the identity and user if they exist identity = Identity.find_for_oauth(auth) user = identity.user if user.nil? # Get the existing user by email if the OAuth provider gives us a verified email # If the email has not been verified yet we will force the user to validate it email = auth.extra.email || auth.extra.raw_info.email user = User.where(:email => email).first if email # Create the user if it is a new registration if user.nil? if auth.provider.downcase == "infinum" user = User.new( first_name: auth.extra.first_name, last_name: auth.extra.last_name, #username: auth.info.nickname || auth.uid, email: auth.extra.email, password: Devise.friendly_token[0,20] ) else user = User.new( first_name: auth.extra.raw_info.first_name, last_name: auth.extra.raw_info.last_name, #username: auth.info.nickname || auth.uid, email: auth.extra.raw_info.email, password: Devise.friendly_token[0,20] ) end user.save! end # Associate the identity with the user if not already if identity.user != user identity.user = user identity.save! end end user end end
Version data entries
3 entries across 3 versions & 1 rubygems