devise_token_auth icon indicating copy to clipboard operation
devise_token_auth copied to clipboard

User Concern is removing Devise settings

Open jeffrfinn opened this issue 9 years ago • 10 comments

When I include include DeviseTokenAuth::Concerns::User

below my devise settings devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :omniauth_providers => [:facebook, :google_oauth2] include DeviseTokenAuth::Concerns::User

I am getting the following error Mapping omniauth_callbacks on a resource that is not omniauthable (ArgumentError) Please add devise :omniauthable to the User model

I looked at the source code for https://github.com/lynndylanhurley/devise_token_auth/blob/master/app/models/devise_token_auth/concerns/user.rb

I think the problem might be with

Hack to check if devise is already enabled

unless self.method_defined?(:devise_modules)
  devise :database_authenticatable, :registerable,
      :recoverable, :trackable, :validatable, :confirmable
else
  self.devise_modules.delete(:omniauthable)
end

I am using Rails 4.2 devise (3.5.1) devise_token_auth (0.1.31) omniauth (1.2.2) omniauth-facebook (2.0.1) omniauth-google-oauth2 (0.2.6) omniauth-oauth2 (1.3.1)

jeffrfinn avatar Jul 26 '15 08:07 jeffrfinn

+1, Any word on this, I am running into the same issue.

nitsujri avatar Sep 05 '15 16:09 nitsujri

I simply re-add omni auth.

devise :database_authenticatable, :async, :registerable,
       :recoverable, :rememberable, :trackable, :validatable, 
       :omniauthable, :omniauth_providers => [:facebook]
include DeviseTokenAuth::Concerns::User
devise :omniauthable # Because for some reason it gets rid of it.

nitsujri avatar Sep 06 '15 10:09 nitsujri

+1, Also hit the issue when using the gem under a scope.

ACPK avatar Nov 02 '15 18:11 ACPK

+1

aaronshim avatar Nov 28 '16 09:11 aaronshim

Same here :/

gfauredumont avatar Dec 03 '16 18:12 gfauredumont

This gem...

BenMorganIO avatar Dec 22 '16 16:12 BenMorganIO

Noting this is still a problem.

KaraAJC avatar Mar 23 '17 22:03 KaraAJC

+1

birdsean avatar Jun 14 '17 17:06 birdsean

+1 still an issue, is there a way a solve it?

mahmoudayoub avatar Jun 01 '22 07:06 mahmoudayoub

Issue is still present 😬 This commit is the one that introduced that delete statement. The reason(commit message) kinda make sense. I think they are expecting us not to directly setup omniauth in the model, but separately, like mentioned in Devise docs It looks like this is necessary only when having more than one auth model; if that's not your case then this will cause only no-needed extra configuration

IMHO I'd remove that delete statement and just add an entry in the docs explaining the incompatibility issue

itsmeurbi avatar May 18 '23 23:05 itsmeurbi