Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User < ActiveRecord::Base
- # Include default devise modules. Others available are:
- # :token_authenticatable, :confirmable, :lockable and :timeoutable
- devise :database_authenticatable, :registerable,
- :recoverable, :rememberable, :trackable, :validatable
- # Setup accessible (or protected) attributes for your model
- attr_accessible :email, :password, :password_confirmation, :remember_me
- has_many :authentications
- def apply_omniauth(omniauth)
- if email.blank?
- self.email = omniauth['user_info']['email'] ||
- omniauth['extra']['user_hash']['email']
- end
- if name.blank?
- self.name = omniauth['user_info']['first_name'] + ' ' +
- omniauth['user_info']['last_name']
- end
- authentications.build(
- :provider => omniauth['provider'],
- :uid => omniauth['uid']
- )
- end
- def password_required?
- (authentications.empty? || !password.blank?) && super
- end
- end
Add Comment
Please, Sign In to add comment