login consistency fix; limit length of user names to 35

This commit is contained in:
Max-Wilhelm Bruker 2011-02-23 23:46:18 +01:00
parent a4552a1596
commit 102e246c6d
5 changed files with 27 additions and 2 deletions

View file

@ -38,6 +38,8 @@ Server::~Server()
AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString &name, const QString &password)
{
if (name.size() > 35)
name = name.left(35);
AuthenticationResult authState = checkUserPassword(name, password);
if (authState == PasswordWrong)
return authState;
@ -47,10 +49,11 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
if (oldSession)
delete oldSession; // ~Server_ProtocolHandler() will call Server::removeClient
} else if (authState == UnknownUser) {
// Change user name so that no two users have the same names
// Change user name so that no two users have the same names,
// don't interfere with registered user names though.
QString tempName = name;
int i = 0;
while (users.contains(tempName))
while (users.contains(tempName) || userExists(tempName))
tempName = name + "_" + QString::number(++i);
name = tempName;
}