Почему devise_token_auth нарушают маршруты ванильного устройства? - PullRequest
0 голосов
/ 18 апреля 2019

Я использую devise и devise_token_auth в своем приложении Rails5. Разработайте omniauth (facebook / google) для Интернета и devise_token_auth для мобильного приложения.

я определил маршруты с:

scope module: 'api' do
  namespace :v1 do
    mount_devise_token_auth_for 'User', at: 'auth'
  end
end

devise_for :users, :controllers => { :omniauth_callbacks => "callbacks" }, as: 'auth'
resources :users

и получите несколько маршрутов

=========================TOKEN AUTH=======================================
 new_v1_user_session GET        /v1/auth/sign_in(.:format)                           devise_token_auth/sessions#new
                           v1_user_session POST       /v1/auth/sign_in(.:format)                           devise_token_auth/sessions#create
                   destroy_v1_user_session DELETE     /v1/auth/sign_out(.:format)                          devise_token_auth/sessions#destroy
                      new_v1_user_password GET        /v1/auth/password/new(.:format)                      devise_token_auth/passwords#new
                     edit_v1_user_password GET        /v1/auth/password/edit(.:format)                     devise_token_auth/passwords#edit
                          v1_user_password PATCH      /v1/auth/password(.:format)                          devise_token_auth/passwords#update
                                           PUT        /v1/auth/password(.:format)                          devise_token_auth/passwords#update
                                           POST       /v1/auth/password(.:format)                          devise_token_auth/passwords#create
               cancel_v1_user_registration GET        /v1/auth/cancel(.:format)                            devise_token_auth/registrations#cancel
                  new_v1_user_registration GET        /v1/auth/sign_up(.:format)                           devise_token_auth/registrations#new
                 edit_v1_user_registration GET        /v1/auth/edit(.:format)                              devise_token_auth/registrations#edit
                      v1_user_registration PATCH      /v1/auth(.:format)                                   devise_token_auth/registrations#update
                                           PUT        /v1/auth(.:format)                                   devise_token_auth/registrations#update
                                           DELETE     /v1/auth(.:format)                                   devise_token_auth/registrations#destroy
                                           POST       /v1/auth(.:format)                                   devise_token_auth/registrations#create
                  new_v1_user_confirmation GET        /v1/auth/confirmation/new(.:format)                  devise_token_auth/confirmations#new
                      v1_user_confirmation GET        /v1/auth/confirmation(.:format)                      devise_token_auth/confirmations#show
                                           POST       /v1/auth/confirmation(.:format)                      devise_token_auth/confirmations#create
                    v1_auth_validate_token GET        /v1/auth/validate_token(.:format)                    devise_token_auth/token_validations#validate_token
                           v1_auth_failure GET        /v1/auth/failure(.:format)                           devise_token_auth/omniauth_callbacks#omniauth_failure
                                           GET        /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
                                           GET        /v1/auth/:provider(.:format)                         redirect(301)


======================WEB==========================================


                     new_auth_user_session GET        /users/sign_in(.:format)                             devise/sessions#new
                         auth_user_session POST       /users/sign_in(.:format)                             devise/sessions#create
                 destroy_auth_user_session DELETE     /users/sign_out(.:format)                            devise/sessions#destroy
                    new_auth_user_password GET        /users/password/new(.:format)                        devise/passwords#new
                   edit_auth_user_password GET        /users/password/edit(.:format)                       devise/passwords#edit
                        auth_user_password PATCH      /users/password(.:format)                            devise/passwords#update
                                           PUT        /users/password(.:format)                            devise/passwords#update
                                           POST       /users/password(.:format)                            devise/passwords#create
             cancel_auth_user_registration GET        /users/cancel(.:format)                              devise/registrations#cancel
                new_auth_user_registration GET        /users/sign_up(.:format)                             devise/registrations#new
               edit_auth_user_registration GET        /users/edit(.:format)                                devise/registrations#edit
                    auth_user_registration PATCH      /users(.:format)                                     devise/registrations#update
                                           PUT        /users(.:format)                                     devise/registrations#update
                                           DELETE     /users(.:format)                                     devise/registrations#destroy
                                           POST       /users(.:format)                                     devise/registrations#create
                new_auth_user_confirmation GET        /users/confirmation/new(.:format)                    devise/confirmations#new
                    auth_user_confirmation GET        /users/confirmation(.:format)                        devise/confirmations#show
                                           POST       /users/confirmation(.:format)                        devise/confirmations#create
auth_user_google_oauth2_omniauth_authorize GET|POST   /omniauth/google_oauth2(.:format)                    callbacks#passthru
 auth_user_google_oauth2_omniauth_callback GET|POST   /omniauth/google_oauth2/callback(.:format)           callbacks#google_oauth2
     auth_user_facebook_omniauth_authorize GET|POST   /omniauth/facebook(.:format)                         callbacks#passthru
      auth_user_facebook_omniauth_callback GET|POST   /omniauth/facebook/callback(.:format)  

но маршруты для интернета должны быть похожи на

auth_user_google_oauth2_omniauth_authorize GET|POST   /users/auth/google_oauth2(.:format)                  callbacks#passthru
 auth_user_google_oauth2_omniauth_callback GET|POST   /users/auth/google_oauth2/callback(.:format)         callbacks#google_oauth2
     auth_user_facebook_omniauth_authorize GET|POST   /users/auth/facebook(.:format)                       callbacks#passthru
      auth_user_facebook_omniauth_callback GET|POST   /users/auth/facebook/callback(.:format) 

Когда я комментирую devise_token_auth initializer, все веб-маршруты в порядке, но когда я включаю инициализатор - он не работает. Инициализаторы для devise и token_auth являются значениями по умолчанию.

как я могу это исправить?

...