This is great! But I am having a bit of an issue. I can not seem to get it to bypass the password as easily as it should be.
I am allowing login via facebook using the information from this railscasts. My resource is :subscriber instead of :user, but the rest is pretty much the same.
ruby
classOmniauthCallbacksController < Devise::OmniauthCallbacksControllerdefall
subscriber = Subscriber.from_omniauth(request.env["omniauth.auth"])
if subscriber.persisted?
sign_in_and_redirect subscriber, notice:"Signed in!"else
.....the rest of what you see in the railscasts
and my model contains:
ruby
# populates db with information from omniauth'ed subscriber(facebook) defself.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_create do |subscriber|
subscriber.provider = auth.provider
subscriber.uid = auth.uid
subscriber.email = auth.info.email
subscriber.firstname = auth.info.first_name
subscriber.lastname = auth.info.last_name
endend# persists subscriber information through the session # when omniauth'ed subscriber (facebook) defself.new_with_session(params, session)
if session["devise.subscriber_attributes"]
new(session["devise.subscriber_attributes"], without_protection:true) do |subscriber|
subscriber.attributes = params
subscriber.valid?
endelsesuperendenddefpassword_required?super && provider.blank?
end
When I run debugger and interject immediately before subscriber.persisted? I can see I have a provider and a uid for subscriber, but subscriber.persisted? returns false because subscriber.new_record? is true.
Nevermind... I found out my issue was that in the model I was still validating the presence of several fields (including the password).
This is great! But I am having a bit of an issue. I can not seem to get it to bypass the password as easily as it should be.
I am allowing login via facebook using the information from this railscasts. My resource is :subscriber instead of :user, but the rest is pretty much the same.
and my model contains:
When I run debugger and interject immediately before
subscriber.persisted?
I can see I have a provider and a uid for subscriber, butsubscriber.persisted?
returns false becausesubscriber.new_record?
is true.What am I missing?