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

devise_token_auth for public API, but devise for rest of app? #114

Closed
jdgblinq opened this issue Jan 13, 2015 · 5 comments
Closed

devise_token_auth for public API, but devise for rest of app? #114

jdgblinq opened this issue Jan 13, 2015 · 5 comments

Comments

@jdgblinq
Copy link

Hello,

We have a rails application with a public JSON API. The same application also has an administrative interface that does not rely on the public JSON API; it's just vanilla Rails. Our AngularJS frontend is a separate application on a separate host. We don't use AngularJS in our Rails app.

In your examples, it seems like everything uses ng-token-auth. Is it possible to use devise_token_auth without ng-token-auth? In other words, can we use devise_token_auth with vanilla Rails forms?

Alternatively, is it possible to limit devise_token_auth to certain routes and use regular devise for the remaining routes?

Thanks,

Jesse

@lynndylanhurley
Copy link
Owner

Is it possible to use devise_token_auth without ng-token-auth? In other words, can we use devise_token_auth with vanilla Rails forms?

Yes it is possible, but the client application will need to implement the functionality of ng-token-auth.

This includes:

  • Token management (validation, expiration, persistence, etc.)
  • OAuth success/failure handling
  • Registration success/failure handling
  • Password reset submission / confirmation
  • Multiple user type support introduces additional problems

Alternatively, is it possible to limit devise_token_auth to certain routes and use regular devise for the remaining routes?

The best way to accomplish this will be to mount the standard devise routes to one path, and to route the devise_token_auth routes to a separate path. Something like this:

Rails.application.routes.draw do

  # standard devise routes available at /users
  devise_for :users

  # token auth routes available at /api/v1/auth
  namespace :api do
    scope :v1 do
      mount_devise_token_auth_for 'User', at: 'auth'
    end
  end

end

@jdgblinq
Copy link
Author

This works quite well. Thank you.

@lynndylanhurley
Copy link
Owner

🤘

@dyaa
Copy link

dyaa commented Mar 20, 2015

🤘 ✌️

@Jefferson210
Copy link

Hi @jdgblinq, What is the configuration of the controllers?

I perform the configuration as indicated @lynndylanhurley in the routes but it still does not work.

thanks for your help.

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

4 participants