You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding devise_token_auth into an existing rails + devise setup, we found it necessary to put devise_token_auth and the associated api into a namespace, in a similar approach to what jotolo did here:
namespace :api, defaults: {format: 'json'} do
scope :v1 do
mount_devise_token_auth_for 'User', at: 'auth', skip: [ :verify_authenticity_token ]
resources :items, only: [:index, :show, :create]
end
end
We've gotten this to work for the most part, but rather troubling is that by mounting devise in this namespace, we expect the paths/urls to be contained to this namespace /api/v1 but instead devise_token_auth overrides devise's regular routes with its own implementations.
Examples of this is that omniauth implementations broke, forms use the wrong action urls, and accessing protected pages while unauthenticated returns a simpletext page instead of a redirect to login, that devise gives you.
Commenting out the mount_devise line fixes our forms, our omniauth, and everything else
The core of the issue here appears to be that even placing this inside a scoped namespace, devise_token_auth still overrides the root routes anyway.
We're trying to migrate from a server-side-rendered app to a react app with token auth, but this gem overriding devises routes breaks the existing rails app.
Version: 1.0.0
Environmental Info:
Gems: Rails, Devise, DeviseTokenAuth, ActiveAdmin
Custom Frontend: Existing app is ordinary rails, new app is react-based
The text was updated successfully, but these errors were encountered:
namespace :api do
namespace :v1 do
namespace :admin do
mount_devise_token_auth_for "Administrator", at: "", controllers: {
sessions: "api/v1/admin/sessions"
}
resources :home, only: :index
end
end
end
The same problem.
But below code run.
namespace :api do
namespace :v1 do
namespace :admin do
resources :home, only: :index
mount_devise_token_auth_for "Administrator", at: "", controllers: {
sessions: "api/v1/admin/sessions"
}
end
end
end
Hello,
When adding devise_token_auth into an existing rails + devise setup, we found it necessary to put devise_token_auth and the associated api into a namespace, in a similar approach to what jotolo did here:
#120 (comment)
Our implementation was as follows:
We've gotten this to work for the most part, but rather troubling is that by mounting devise in this namespace, we expect the paths/urls to be contained to this namespace /api/v1 but instead devise_token_auth overrides devise's regular routes with its own implementations.
Examples of this is that omniauth implementations broke, forms use the wrong action urls, and accessing protected pages while unauthenticated returns a simpletext page instead of a redirect to login, that devise gives you.
Commenting out the mount_devise line fixes our forms, our omniauth, and everything else
The core of the issue here appears to be that even placing this inside a scoped namespace, devise_token_auth still overrides the root routes anyway.
We're trying to migrate from a server-side-rendered app to a react app with token auth, but this gem overriding devises routes breaks the existing rails app.
The text was updated successfully, but these errors were encountered: