devise_token_auth: Cannot use this gem alongside Devise
Hello. I cannot find a way to use this gem. I’m working on a Ionic app and I need Angular authentication. I don’t need Omniauth, mail and password login. Very simple.
I follow every step in the installation. I have a working Rails 4.1 app with Device installed and I’m using the beta 8 of Devise_token_auth.
I modify the migration file because I need only a couple of fields:
== 20150318160543 DeviseTokenAuthCreateUsers: migrating =======================
-- add_column(:users, :tokens, :text)
-> 0.0014s
-- add_column(:users, :uid, :string, {:null=>false, :default=>""})
-> 0.0439s
== 20150318160543 DeviseTokenAuthCreateUsers: migrated (0.0455s) ==============
In my user.rb I have
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :confirmable, :validatable
include DeviseTokenAuth::Concerns::User
In my api base controller I have
module Api
class BaseController < ApplicationController
include DeviseTokenAuth::Concerns::SetUserByToken
respond_to :json
end
end
In my routes I have
namespace :api do
namespace :v1 do
mount_devise_token_auth_for 'User', at: 'auth', skip: [:omniauth_callbacks]
resources :contents, only: [:index, :show] do
get :hottest, on: :collection
end
end
end
The result is
uninitialized constant ActionDispatch::Routing::Mapper::Scope
A brief question: how can I secure only update, post and delete method in my api?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 25 (6 by maintainers)
@BecomingSam I’ve given up using the gem and followed a tutorial to implement the API authentication system myself: you can find it here
@aliceclv for the amount of effort in “roll your own” wouldn’t it be possible to fix and pull request?