lynndylanhurley / devise_token_auth

Token based authentication for Rails JSON APIs. Designed to work with jToker and ng-token-auth.
Do What The F*ck You Want To Public License
3.54k stars 1.13k forks source link

User Concern is removing Devise settings #319

Open jeffrfinn opened 9 years ago

jeffrfinn commented 9 years ago

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)

nitsujri commented 9 years ago

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

nitsujri commented 9 years ago

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.
ACPK commented 8 years ago

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

aaronshim commented 7 years ago

+1

gfauredumont commented 7 years ago

Same here :/

BenMorganIO commented 7 years ago

This gem...

KaraAJC commented 7 years ago

Noting this is still a problem.

birdsean commented 7 years ago

+1

mahmoudayoub commented 2 years ago

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

itsmeurbi commented 1 year ago

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