I'm trying to change nickname.js for  an user authentication on my
database.
The query run well and return correct values from database. But i
can't setproperty name of the user and return 1 to the main script...
Can someone help me understand why cmd.user.setProperty('name',
params.name);
and
return 1;
don't run if they are inside the sql.query callback function?

ThankYou very much!!

this is a portion of my code:

Ape.registerHookCmd("connect", function(params, cmd) {

        if (!$defined(params.name)) return 0;
        if (userlist.has(params.name.toLowerCase())) return ["007",
"NICK_USED"];
        if (params.name.length > 16 || params.name.test('[^a-zA-Z0-9]', 'i'))
return ["006", "BAD_NICK"];
....
.....user_to_check = ....

        var sql = new Ape.MySQL('IP:3306', 'user', 'psw', 'db');

        sql.onConnect = function() {

                sql.query('SELECT id_user FROM users WHERE user_id = "' +
user_to_check + '" LIMIT 1', function(res, errorNo) {

                                                                                
                idsfromdb = res[0].id_user ;
 
if idsfromdb =
                                                                                
                        cmd.user.setProperty('name', params.name);
                                                                                
                        return 1;

                                                                                
                        } else {

                                                                                
                                                return ["006", "BAD_NICK"];

                                                                                
                                         }


                                                                            }

                });



-- 
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