views:

82

answers:

2

I am creating a web app which uses jQuery to authenticate:

$.ajax({
    url: "/session/create?format=json",
    type: "GET",
    dataType: "json",
    cache: false,
    username: $("#signin-email").val(),
    password: $("#signin-password").val(),
    success: function(data) {
      if(data.success) {
        success = true;
      }
    }
  });

The problem is that the code only makes the AJAX-request when the username does not include things like an @ (probably because the @ is a seperator for authentication and host in the URL), which is required in my app. Can anyone help me with how I can do this? I do not mind changing the back-end a little bit, but requiring users to have an @-less email is not an option.

Oh, my back-end is a Ruby-on-Rails app.

A: 

Couldn't replicate described behavior: request is being sent for @-logins. Are you sure that this is not a server problem (e.g. response isn't in json format)? (Btw, I'm using standard jquery, suppose there are no hacks for one that RoR shipped with)

Does Rails ship with jQuery? I didn't know. I usually empty the 'public' folder after I created a new project...No it's not a server problem since when I sign in by entering the URL and fill in the email and password in Safari's dialog, it does work.
Time Machine
The problem seems strange to me to – jQuery seems to pass the username and password params directly to the browser's XMLHttpRequest class, and I would assume any escaping is done automatically...
Joel L
+1  A: 

You should replace all @s with %40. The @ is namely teh seperator between the authentication and host in the URL (e.g. http://someone:[email protected]/

Time Machine