Ajax device authentication doesn't work?

i tried to use the following tutorial for rails api authentication by using json & ajax: http://jessehowarth.com/devise

it seem to work, but no matter what login-credentials i enter (existing and non-existing), it fails everytime i hit submit.

i make the request using node.js

var post_data = querystring.stringify({
      'email' : 'foo@bar.com',
      'password': 'foo',
      'remember_me': 1
  });

  var options = {
    host: 'localhost',
    path: '/users/sign_in.json',
    port: '3000',
    method: 'POST'
  };

  callback = function(response) {
    var str = '';
    response.on('data', function (chunk) {
      str += chunk;
    });

    response.on('end', function () {
      console.log(str);
    });
  }

  var req = http.request(options, callback);
  req.write(post_data);
  req.end();

my devise-session controller looks like this:

class SessionsController < Devise::SessionsController

  def create
    respond_to do |format|
      format.html{ super }
      format.json do
       resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#failure")
       return sign_in_and_redirect(resource_name, resource)
      end
    end
  end

  def sign_in_and_redirect(resource_or_scope, resource=nil)
    scope = Devise::Mapping.find_scope!(resource_or_scope)
    resource ||= resource_or_scope
    sign_in(scope, resource) unless warden.user(scope) == resource
    respond_to do |format|
      format.json {render :json => {:success => true, :redirect => stored_location_for(scope) || after_sign_in_path_for(resource)}}
      format.html {redirect_to root_url}
    end
  end

  def failure
    respond_to do |format|
      format.json { render:json => {:success => false, :errors => ["Login failed."]} }
    end
  end

end

the output i get:

{"success":false,"errors":["Login failed."]}

any advice on this?

thanks!

Okay, actually it was my fault. but if someone is as silly as me:

I used the parameters email, password and remember_me instead of user[email], user[password] and user[remember_me]

Solved!