I am fixing an application that needs to support duplicate sign in requests being sent to the server (for devise). The requests are sent via JSON. Currently, if I call the following more than once:
curl -v -b cookie.file -c cookie.file -H "Content-Type: application/json" -X POST -d '{"user":{"username":"kevin","password":"password"}}' http://localhost:3000/users/sign_in.json
The first results in a 201 status code and the second results in a 302 that redirects to an HTML page. I’ve overridden the create method in Users::SessionsController, however the custom code is only called on the first POST (nothing happens for the second). Any way to get the second request to not performa redirect? Here is what I have so far:
class Users::SessionsController < Devise::SessionsController
def create
logger.info "Users::SessionController"
super
end
end
I ended up here as I had the same issue. The sign in for non-navigational formats weren’t idempotent as I was redirected to the html-version if I was already authenticated.
This issue has been resolved as of 29th of September with this commit.
As of today you have to use edge devise to get it working with your app.