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

validate_token route omits specified json format #1031

Open
dks17 opened this issue Nov 26, 2017 · 1 comment
Open

validate_token route omits specified json format #1031

dks17 opened this issue Nov 26, 2017 · 1 comment

Comments

@dks17
Copy link
Contributor

dks17 commented Nov 26, 2017

At each request /api/v1/auth/validate_token browser gets response in JSON format, but it is logged like HTML.

rails server log:

Started GET "/api/v1/auth/validate_token" for 127.0.0.1 at 2017-11
Processing by DeviseTokenAuth::TokenValidationsController#validate_token as HTML

In browser response is returned like JSON

Request headers:

Accept: application/json, text/plain, /

Response headers:

Content-Type: application/json; charset=utf-8

routes.rb

scope '/api/v1', defaults: {format: :json} do
  mount_devise_token_auth_for 'User', at: 'auth'
  #
end

rake routes

         user_confirmation POST     /api/v1/auth/confirmation(.:format)       devise_token_auth/confirmations#create {:format=>:json}
     new_user_confirmation GET      /api/v1/auth/confirmation/new(.:format)   devise_token_auth/confirmations#new {:format=>:json}
                           GET      /api/v1/auth/confirmation(.:format)       devise_token_auth/confirmations#show {:format=>:json}
api_v1_auth_validate_token GET      /api/v1/auth/validate_token(.:format)     devise_token_auth/token_validations#validate_token
                           GET      /api/v1/auth/validate_token(.:format)     devise_token_auth/token_validations#validate_token
                           GET      /api/v1/auth/validate_token(.:format)     devise_token_auth/token_validations#validate_token
                           GET      /api/v1/auth/validate_token(.:format)     devise_token_auth/token_validations#validate_token
       api_v1_auth_failure GET      /api/v1/auth/failure(.:format)            devise_token_auth/omniauth_callbacks#omniauth_failure
                           GET      /api/v1/auth/:provider/callback(.:format) devise_token_auth/omniauth_callbacks#omniauth_success
                           GET|POST /omniauth/:provider/callback(.:format)    devise_token_auth/omniauth_callbacks#redirect_callbacks
          omniauth_failure GET|POST /omniauth/failure(.:format)               devise_token_auth/omniauth_callbacks#omniauth_failure

I also noticed some strange path helpers name api_v1_auth_validate_token and api_v1_auth_failure. It could be unnoticed when routes were written with namespace.

I don't use omniauth. May further paths be duplicates for GET method?

       api_v1_auth_failure GET      /api/v1/auth/failure(.:format)            devise_token_auth/omniauth_callbacks#omniauth_failure
                           GET      /api/v1/auth/:provider/callback(.:format) devise_token_auth/omniauth_callbacks#omniauth_success
                           GET|POST /omniauth/:provider/callback(.:format)    devise_token_auth/omniauth_callbacks#redirect_callbacks
          omniauth_failure GET|POST /omniauth/failure(.:format)               devise_token_auth/omniauth_callbacks#omniauth_failure

Or did I make something wrong?

@dks17
Copy link
Contributor Author

dks17 commented Nov 26, 2017

#1032 fix only defaults for validate_token path
Log output as expected:

Started GET "/api/v1/auth/validate_token" for 127.0.0.1 at 2017-1
Processing by DeviseTokenAuth::TokenValidationsController#validate_token as JSON

rake routes

api_v1_auth_validate_token GET      /api/v1/auth/validate_token(.:format)     devise_token_auth/token_validations#validate_token {:format=>:json}

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

1 participant