Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User < ActiveRecord::Base
- has_many :ads
- has_many :authentications
- has_many :uploads
- devise :database_authenticatable, :registerable,
- :recoverable, :rememberable, :trackable, :validatable,:omniauthable
- def self.find_for_facebook_oauth(access_token, signed_in_resource=nil)
- data = access_token['extra']['user_hash']
- if user = User.find_by_email(data["email"])
- user
- else # Create a user with a stub password.
- User.create!(:email => data["email"], :password => Devise.friendly_token[0,20])
- end
- end
- def self.new_with_session(params, session)
- super.tap do |user|
- if data = session["devise.facebook_data"] && session["devise.facebook_data"]["extra"]["user_hash"]
- user.email = data["email"]
- end
- end
- end
- def admin?
- self.is_a? Admin
- end
- attr_accessible :email, :password, :password_confirmation, :remember_me
- end
Add Comment
Please, Sign In to add comment