Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes include bug causing sign_in to require auth #1016

Merged
merged 1 commit into from
Nov 12, 2017

Conversation

karlingen
Copy link
Contributor

@karlingen karlingen commented Nov 12, 2017

This fixes #1014, #887 and probably some more issues.

I'm not sure why that line was included in that file in the first place. It is already being loaded inside DeviseTokenAuth::Concerns::ResourceFinder which also is included.

Now I am successfully able to run devise alongside devise_token_auth.

Leave my ApplicationController untouched:

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
  before_action :authenticate_user!
end

and use another controller for the Api:

class Api::ApiController < ActionController::Base
  include DeviseTokenAuth::Concerns::SetUserByToken
end

routes:

namespace :api, defaults: { format: 'json' } do
  scope :v1 do
    mount_devise_token_auth_for 'User', at: 'auth', controllers: { sessions: "users/sessions" }
    resources :test, only: :index
  end
end

@zachfeldman
Copy link
Contributor

All the tests pass so I don't have a huge problem with this. @MaicolBen @lynndylanhurley any issues?

@zachfeldman zachfeldman self-requested a review November 12, 2017 22:19
@lynndylanhurley
Copy link
Owner

Thanks @karlingen. I'm not sure why that concern was included in the first place.

@zachfeldman zachfeldman merged commit 2a5cedb into lynndylanhurley:master Nov 12, 2017
@naseeratevolverstech
Copy link

@karlingen i have tried your solution but it does not work for me. i am using devise for admin and vendor but devise_token_auth for user model making apis for users but when i make auth sign up it shows error invalid authenticity token. and when i wirte protect_from_forgery with: :null_session.in application controller, it signed up successfully and after that when i try to sign in it shows json error user already exits. i am stuck please help me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API is not using defined ApiController but rather ApplicationController
4 participants