Dear APE Team,

 I'm using the below Hook on CONNECT Command, where I'm using Async
Auth.
 The problem is when I make a request to another API to verify the
credentials of the parameters sent in the command, that time I need to
get a response back by using cmd.sendResponse alongwith a LOGIN and
IDENT raw, because I'm sending the values stored on the server to join
a channel
This is happening but the RAW's which I'm receiving are out of Sync
sometimes.

Below is the code that I'm using. Can you please let me know what am I
doing wrong

Ape.registerHookCmd("CONNECT", function(params, cmd) {
    var ClientErrorResponse = "Incorrect User Name or Password";
    if (!((params.username || params.username == 'null') &&
(params.pwd || params.pwd == 'null'))){
        cmd.sendResponse("authfail", {"fail":"true", "response":
{ "errcode":"1", "reason" : ClientErrorResponse}});
        return 0;
    }
    var authurl = "http://localhost/auth.php";;
    var request = new Http(authurl);
    var cookie = "passwd="+params.pwd;
    request.setHeader('COOKIE', cookie);
    request.getContent(function(result) {
    var ret = {};
        try {
            ret = JSON.parse(result);
        } catch(e){
            Ape.log("Caught error in JSON Object Parsing, Data
returned is not in Proper format")
        };
        if(ret.details.respcode == 0){
            Ape.log('Authentication Failure');
            cmd.sendResponse("authfail", {"fail":"true", "response":
{ "errcode":"2", "reason":"Authentication Failure. }});
            return 0;
        }
        if(ret.details.respcode == 1){
            var userkeyname = 'servercookie';
            var secretname =
Ape.sha1.str(decodeURIComponent(params.username));r
            var secretkey = Ape.sha1.str(userkeyname +
decodeURIComponent(params.pwd));
            cmd.user.userkeyname = secretkey;
            cmd.sendResponse("authsuccess", {"fail":"false",
"response":{ "errcode":"0", "reason":"Authentication Success",
"channel" : chan}});
            return 1;
        }
    });
});

Thanks in advance,
Regards,
Sudeep Sunthankar

-- 
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

Reply via email to