Undefined method skip_confirmation! - reinvent omniauth

An attempt to configure facebook authentication using devise, omniauth (including facebook-omniauth) in an application hosted on the hero. The facebook API call works, but after the callback, I can’t miss the confirmation step.

I followed the github tutorial on omniauth: https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview

and also read and tried to implement this: Come up with skip_confirmation! does not work

But I save the following error in my heroku log:

NoMethodError (undefined method `skip_confirmation!') 

This is what my devise.rb looks like:

 config.omniauth :facebook, "API_KEY", "API_SECRET" {:strategy_class => OmniAuth::Strategies::Facebook, :scope => 'email, offline_access', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}} 

Here is my omniauth_callbacks_controller.rb:

 class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController def facebook # You need to implement the method below in your model (eg app/models/user.rb) @user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user) if @user.persisted? sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format? else session["devise.facebook_data"] = request.env["omniauth.auth"] redirect_to new_user_registration_url end end end 

Here is my user.rb model:

 def self.find_for_facebook_oauth(auth, signed_in_resource=nil) user = User.where(:provider => auth.provider, :uid => auth.uid).first unless user user = User.new(name:auth.extra.raw_info.name, provider:auth.provider, uid:auth.uid, email:auth.info.email, password:Devise.friendly_token[0,20], ) user.skip_confirmation! user.save end user end 

Thank you for your help!

+7
source share
1 answer

So, if I am right (not 100% safe), you need to declare that your model has a module confirming, add a confirming module:

  devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :confirmable 

And make sure that you have fields for the module to be confirmed in the table of your users, you must have the confirm_token and confirm_at fields

If you do not have these fields, check this answer how to add them.

+16
source

All Articles