Kranthi
Kranthi

Reputation: 1417

how to skip email confirmation using devise_token_auth?

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 [email protected]. You must follow the instructions in the email before your account can be activated"]}

Upvotes: 1

Views: 2056

Answers (3)

RHFS
RHFS

Reputation: 356

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

Upvotes: 0

SJU
SJU

Reputation: 3272

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

Upvotes: 0

Andrey Deineko
Andrey Deineko

Reputation: 52357

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

Upvotes: 6

Related Questions