By default, almost all of the Devise modules are included:
You may not want all of these features enabled in your app. That's OK! You can mix and match to suit your own unique style.
The following example shows how to disable email confirmation.
Just list the devise modules that you want to include before including the DeviseTokenAuth::Concerns::User
model concern.
# app/models/user.rb
class User < ActiveRecord::Base
# notice this comes BEFORE the include statement below
# also notice that :confirmable is not included in this block
devise :database_authenticatable, :recoverable,
:trackable, :validatable, :registerable,
:omniauthable
# note that this include statement comes AFTER the devise block above
include DeviseTokenAuth::Concerns::User
end
Some features include routes that you may not want mounted to your app. The following example shows how to disable OAuth and its routes.
First instruct the model not to include the omniauthable
module.
# app/models/user.rb
class User < ActiveRecord::Base
# notice that :omniauthable is not included in this block
devise :database_authenticatable, :confirmable,
:recoverable, :trackable, :validatable,
:registerable
include DeviseTokenAuth::Concerns::User
end
Now tell the route helper to skip
mounting the omniauth_callbacks
controller:
Rails.application.routes.draw do
# config/routes.rb
mount_devise_token_auth_for 'User', at: 'auth', skip: [:omniauth_callbacks]
end