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

Two models, one not working #726

Closed
kelvinblade opened this issue Sep 2, 2016 · 2 comments
Closed

Two models, one not working #726

kelvinblade opened this issue Sep 2, 2016 · 2 comments

Comments

@kelvinblade
Copy link

Thank you for writing such a great gem.

I'm having trouble trying two authenticate with 2 models. I followed https://github.com/lynndylanhurley/devise_token_auth#view-live-multi-user-demos

I ran rails g devise_token_auth:install User auth and got:

Running via Spring preloader in process 3396
      create  config/initializers/devise_token_auth.rb
      create  db/migrate/20160902083849_devise_token_auth_create_users.rb
      create  app/models/user.rb
      insert  app/controllers/application_controller.rb
        gsub  config/routes.rb

I ran rails g devise_token_auth:install Employer employer_auth and got:

Running via Spring preloader in process 3490
       identical  config/initializers/devise_token_auth.rb
          create  db/migrate/20160902084155_devise_token_auth_create_employers.rb
          create  app/models/employer.rb
         skipped  Concern is already included in the application controller.
            gsub  config/routes.rb
            gsub  config/routes.rb

routes:

mount_devise_token_auth_for 'User', at: 'auth'
mount_devise_token_auth_for 'Employer', at: 'employer_auth'

authenticate_user!, user_signed_in? and current_user works
authenticate_employer!, employer_signed_in? and current_employer does not work.

authenticate_employer! returns {"errors":["Authorized users only."]}
employer_signed_in? returns false
current_employer returns nil

it seems like a problem with the access token in the header but i'm not too sure.

i'm using rails5.0
devise 4.2.0
devise_token_auth 0.1.38

Any help would be greatly appreciated.

@kelset
Copy link

kelset commented Sep 8, 2016

Hey, I think you are a bit too generic: can you provide the Controller in which you call the methods which are not working?

Can you past also your applicationController? I think that could help.

@kelvinblade
Copy link
Author

I am just using the default devise controller, I didn't generate my own

here's my application controller:

class ApplicationController < ActionController::API
  include DeviseTokenAuth::Concerns::SetUserByToken
end

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