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

forward skip to devise #97

Closed
nean opened this issue Jan 2, 2015 · 7 comments
Closed

forward skip to devise #97

nean opened this issue Jan 2, 2015 · 7 comments

Comments

@nean
Copy link

nean commented Jan 2, 2015

At present we can skip controllers in devise_token_auth but devise registers its own controllers.
i suggest we also pass the skip to devise_for here?

@lynndylanhurley
Copy link
Owner

@nean - I'm not sure I understand the problem. Can you post the code that you're using to include the devise token auth modules?

@nean
Copy link
Author

nean commented Jan 2, 2015

In a test app with just devise_token_auth
config/routes.rb

    mount_devise_token_auth_for 'User', at: '/user', skip: [:omniauth_callbacks, :sessions]

rake routes

                  Prefix Verb   URI Pattern                       Controller#Action
        new_user_session GET    /v1/user/sign_in(.:format)        devise/sessions#new
            user_session POST   /v1/user/sign_in(.:format)        devise/sessions#create
    destroy_user_session DELETE /v1/user/sign_out(.:format)       devise/sessions#destroy
           user_password POST   /v1/user/password(.:format)       devise_token_auth/passwords#create
       new_user_password GET    /v1/user/password/new(.:format)   devise_token_auth/passwords#new
      edit_user_password GET    /v1/user/password/edit(.:format)  devise_token_auth/passwords#edit
                         PATCH  /v1/user/password(.:format)       devise_token_auth/passwords#update
                         PUT    /v1/user/password(.:format)       devise_token_auth/passwords#update
cancel_user_registration GET    /v1/user/cancel(.:format)         devise_token_auth/registrations#cancel
       user_registration POST   /v1/user(.:format)                devise_token_auth/registrations#create
   new_user_registration GET    /v1/user/sign_up(.:format)        devise_token_auth/registrations#new
  edit_user_registration GET    /v1/user/edit(.:format)           devise_token_auth/registrations#edit
                         PATCH  /v1/user(.:format)                devise_token_auth/registrations#update
                         PUT    /v1/user(.:format)                devise_token_auth/registrations#update
                         DELETE /v1/user(.:format)                devise_token_auth/registrations#destroy
          validate_token GET    /v1/user/validate_token(.:format) devise_token_auth/token_validations#validate_token

I want to skip :sessions controller totally, but here the sessions controller of devise_token_auth is skipped but devise registers its built in sessions controller.

So i suggest to forward skip to devise something like this

        devise_for resource.pluralize.underscore.to_sym,
          :class_name  => resource,
          :module      => :devise,
          :path        => "",
          :controllers => controllers
          :skip => opts[:skip]

@lynndylanhurley
Copy link
Owner

Oh I see, thanks. I'll push this fix tomorrow.

@lynndylanhurley
Copy link
Owner

Hi @nean, which version are you using?

Module exclusion support was just added in version 0.1.31.beta1. I can't replicate this issue using the latest beta. Is it possible that you're using version 0.1.30?

I even added a test, and it's passing.

@nean
Copy link
Author

nean commented Jan 5, 2015

I used the latest version 0.1.31.beta1 and just updated to 0.1.31.beta2

The test passed because the user model in the test doesn't have :registerable module.

My user model still has :registerable module attached to it so that's why I see the default devise routes.

I want to remove some unnecessary routes defined by devise_token_auth like this one #100.

so i skipped the controller registration and register them mannually like this in routes.rb

scope 'auth' do
  as :user do
    # Sessions
    post 'sign_in', :to => 'devise_token_auth/sessions#create'
    delete 'sign_out', :to => 'devise_token_auth/sessions#destroy'
  end
end

i used this SO question as reference
http://stackoverflow.com/a/6883757

@lynndylanhurley
Copy link
Owner

Ok @nean, try 0.1.31.beta4. I just pushed Rails 4.2 support in 0.1.31.beta3, so let me know if you run into any issues with that as well.

@nean
Copy link
Author

nean commented Jan 5, 2015

works good, @lynndylanhurley ty for the gem

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

No branches or pull requests

2 participants