1

I'm using devise_token_auth gem for my Rails app. I want to login into application once the user sign_up is done. How can I skip confirmation.

I tried config.reconfirmable = false but no luck

Can anyone suggest me or help me how can I achieve this? I tried the solution provided

Why won't Devise allow unconfirmed users to login even when allow_unconfirmed_access_for is set? But still ending up with

{"success":false,"errors":["A confirmation email was sent to your account at test123@gmail.com. You must follow the instructions in the email before your account can be activated"]}
Community
  • 1
  • 1
Kranthi
  • 1,377
  • 1
  • 17
  • 34

3 Answers3

6

Add the following callback the model definition:

before_save -> { skip_confirmation! }

And remove :confirmable from included devise modules:

  devise :database_authenticatable, :recoverable,
         :trackable, :validatable, :registerable,
         :omniauthable # there is no :confirmable here
Andrey Deineko
  • 51,333
  • 10
  • 112
  • 145
0

Alternatively, if you want to skip sending email confirmation for some people but keep sending it for other (based on email address for example) you can do something like that.

# app/models/user.rb
after_create :skip_confirmation_email_for_some_user

# ...

protected
  def skip_confirmation_email_for_some_user
    if self.email.include? "noconfirm"
      self.skip_confirmation!
      self.confirm
    end
  end

Tested on Rails 5.1.6 and Devise Token Auth 0.2.0

ZazOufUmI
  • 3,212
  • 6
  • 37
  • 67
0

In case someone has this error,include DeviseTokenAuth::Concerns::User should be after devise :database_authenticable... https://github.com/lynndylanhurley/devise_token_auth/issues/397#issuecomment-166113011

RHFS
  • 356
  • 2
  • 9