1

I am trying to rescue_from a JWT::DecodeError caused by an invalid token when signing out using devise. But it's not working. I keep getting a JWT::DecodeError. Sessions controller:

class SessionsController < Devise::SessionsController

  rescue_from JWT::DecodeError do |exception|
    render json: { response: "Token is invalid!" }, status: :bad_request
  end render
end
Ruby
  • 21
  • 3
  • Hi Ruby, I just run into the same issue. In my case it looks like the serialization fails - i don't know why actually and didn't have the time to dive deeper into the issue. For now I do have a workaround: I only render the status. in my opinion if decoding of the jwt didn't work, the user is `:unauthorized` - pretty clear status code and I don't actually need the response body – bopa Jun 02 '21 at 15:44

0 Answers0