ruby on rails - Custom devise session controller error with json -


i'm using devise simple-token-authentication user authenticate in restfull webservice. when make requisition invalid token, error below. can do?

started "/users/sign_in.json" ::1 @ 2015-04-22 16:09:27 -0300 processing sessionscontroller#new json completed 406 not acceptable in 4ms  actioncontroller::unknownformat (actioncontroller::unknownformat):   responders (2.1.0) lib/action_controller/respond_with.rb:205:in `respond_with'   devise (3.4.1) app/controllers/devise/sessions_controller.rb:11:in `new'   actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'   actionpack (4.2.0) lib/abstract_controller/base.rb:198:in `process_action'   actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action'   actionpack (4.2.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action' 

i solved problem with

class sessionscontroller < devise::sessionscontroller   respond_to :html, :json    def new     self.resource = resource_class.new(sign_in_params)     clean_up_passwords(resource)     yield resource if block_given?     respond_with(resource, serialize_options(resource)) |format|       format.json { render :json => { :message => "forbidden"},:status => :unauthorized }     end   end   ... end 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

c++ - No viable overloaded operator for references a map -

java - UML - How would you draw a try catch in a sequence diagram? -