Is inside the connect hook,
I am setting properties inside the else if there is not error
callback,
if(error){
Ape.log('There was an error in the query
'+this.errorString()+'');
}else{
var isauthorized;
if(res != ''){
isauthorized = res[0].isauthorized;
}
if
(isauthorized)user.setProperty('isauthorized', isauthorized);
}
inside the mysql query..
but that doesnt work, works but properties are set too late..
I am trying something like this:
Ape.registerHookCmd("connect", function(params, cmd) {
if (!$defined(params) || !$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"];
var res, isauthorized;
cmd.user.setProperty('name', params.name);
cmd.user.setProperty('ip', cmd.ip);
res = setloggedinProperties(cmd.user);
if (res)cmd.user.setProperty('isauthorized', res);
return 1;
});
function setloggedinProperties(user){
var usernick = user.getProperty('name').toLowerCase();
sql.query('SELECT * FROM pfc_login WHERE BINARY
username="'+Ape.MySQL.escape(usernick)+'"',function(res,error){
if(error){
Ape.log('There was an error in the query
'+this.errorString()+'');
}else{
if(res != ''){
return res[0].isauthorized;
}
}
});
}
I got return inside the query but doesn't return to the parent
function...
what should I do...
--
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/