deployd authentification using jquery ajax

Posted by user2507987 on Stack Overflow See other posts from Stack Overflow or by user2507987
Published on 2013-06-21T07:21:02Z Indexed on 2013/06/28 4:21 UTC
Read the original article Hit count: 115

I have installed deployd in my debian 7.0.0 64 bit, I have also succesfully installed mongodb in it, I have create some collection and user collection in deployd dashboard, then using user guide how to connect and query the table in deployd, I choose jquery ajax to log in to deployd from my localhost site and after login success I try to get/post some data, but somehow deployd return access denied. I have create collection name it people, and then at the GET, POST, PUT Event I have write this code :

cancelUnless(me, "You are not logged in", 401);

then using this ajax code, I try to login and POST new people data:

$(document).ready(function(){
/* Create query for username and password for login */
var request = new Object;
request.username = 'myusername';
request.password = 'mypassword';
submitaddress = "http://myipaddress:myport/users/login";
$.ajax({ 
    type: "POST",
    url: submitaddress,
    data: request, 
    cache: false, 
    success: function(data){
        var returndata = eval(data);
        /* After Login success try to post people data */
        if (returndata){
            var request2 = new Object;
            request2.name = 'People Name';
            submitaddress2 = "http://myipaddress:myport/people";
                $.ajax({ 
                    type: "POST",
                    url: submitaddress2,
                    data: request2, 
                    cache: false, 
                    success: function(){
                    }
                })  
            }
        }
    }
});

})

The login process success, it's return session id and my user id, but after login success and I try to POST people data it's return "You are not logged in", can anyone help me, what is the correct way to login to deployd using jquery from other website(cross domain)?

© Stack Overflow or respective owner

Related posts about jquery-ajax

Related posts about authentication