Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Devise authentication respond to JSON only?

How to disable in Devise handling of HTML and XML requests and leave JSON only?

like image 698
Paul Avatar asked Mar 04 '13 15:03

Paul


1 Answers

I imagine you could override the Devise Controllers:

In controllers/devise_overrides/sessions_controller.rb:

class DeviseOverrides::SessionsController < Devise::SessionsController

  respond_to :json
  respond_to :html, only: []
  respond_to :xml, only: []

end

In routes.rb:

devise_for :users, controllers: {
  sessions:  "devise_overrides/sessions"
}
like image 84
RobHeaton Avatar answered Sep 27 '22 18:09

RobHeaton