Banned users and customLogin
Posted: 04 May 2009, 22:11
SmartFoxServer PRO 1.6.6 Trial.
Server side config.xml (customLogin="true"):
Extention Avatar.as:
Client side:
Login in lower case:
If user alex is not banned login is successful and response handled with onExtensionResponse(). OK.
If user alex is banned login is FAILED and response handled with onLogin(). Why with onLogin()? Why handleInternalEvent() didn't process this request ?
var obj = _server.loginUser(nick, pass, chan);
obj.success = false and obj.error should contain message "You have been banned!", right?
Login with upper case:
If user alex is not banned login is successful and response handled with onExtensionResponse(). OK.
If user alex(not Alex) is banned login ( _server.loginUser(nick, pass, chan); ) is successful(why?) and response handled with onExtensionResponse().
Server side config.xml (customLogin="true"):
Code: Select all
<Zone name="avatarZone" maxUsers="10" emptyNames="false" customLogin="true" >
<Rooms>
<Room name="Main Area" maxUsers="10" isPrivate="false" isTemp="false" autoJoin="true" uCountUpdate="true" />
</Rooms>
<Extensions>
<extension name="Avatar" className="Avatar.as" type="script" />
</Extensions>
</Zone>Code: Select all
function init()
{
userList = new Object();
userList["alex"] = "somePass";
}
function handleInternalEvent(evt)
{
if (evt.name == "loginRequest")
{
var error = "";
var nick = evt.nick.toLowerCase(); // << the nickname is NOT case sensitive
var pass = evt.pass;
var chan = evt.chan;
if (userList[nick] != pass)
{
error = "Login failed!";
}
else
{
var obj = _server.loginUser(nick, pass, chan);
if (obj.success == false)
error = obj.error;
}
var response = new Object();
if (error == "")
{
response._cmd = "login";
response.name = nick;
}
else
{
response._cmd = "login";
response.err = error;
}
_server.sendResponse(response, -1, null, chan);
}
}Login in lower case:
Code: Select all
sfs.addEventListener(SFSEvent.onExtensionResponse, onExtensionResponse);
sfs.addEventListener(SFSEvent.onLogin, onLogin);
sfs.login("avatarZone", "alex", "somePass");
If user alex is banned login is FAILED and response handled with onLogin(). Why with onLogin()? Why handleInternalEvent() didn't process this request ?
var obj = _server.loginUser(nick, pass, chan);
obj.success = false and obj.error should contain message "You have been banned!", right?
Login with upper case:
Code: Select all
sfs.addEventListener(SFSEvent.onExtensionResponse, onExtensionResponse);
sfs.addEventListener(SFSEvent.onLogin, onLogin);
sfs.login("avatarZone", "Alex", "somePass");If user alex(not Alex) is banned login ( _server.loginUser(nick, pass, chan); ) is successful(why?) and response handled with onExtensionResponse().