browserquest/BrowserQuest — pull request #132 by sergkr (2013-09-20 04:40:14+00:00)
Title: Fixes issue #115 (logging in with invalid character results in creating a new character)

The HELLO message was replaced with two new message types, CREATE and LOGIN, which are now handled separately on the server. Quite a few changes, but fairly straightforward.

As of this pull request, there are at least four error conditions that could occur during the login / new character creation process:
* Attempting to log in with a valid user but an incorrect password
* Attempting to log in with a non-existent user
* Attempting to create a new user, but the username is already taken
* Attempting to log in as a user who is already logged in

Let me know if you can think of any other wonky cases we might not be handling at the moment.

There are two gray areas I wasn't too sure about:

* **Guilds**: It looks like we have partial support for guilds, but I'm not sure of the status, as there were swaths of code related to guilds that were either commented out or otherwise appeared to be non-functional. In particular, see my changes in gameclient.js. There were two versions of sendHello in there, and the one that appears to have support for guilds was commented out, so it appears logging in as a guild member did not work previously. As such, I didn't bother with guild support when making my changes. If guilds were meant to be functional, perhaps we should make this a separate issue?

* **Banned players**: From the code, it looks like it might be possible to ban players by IP address (see checkBan and banPlayer functions in server/js/db_providers/redis.js). However, I'm not sure how this functionality works and how to go about testing it. I left in the call to checkBan in server/js/player.js, but it's only there for the login case, and not the create new user case. As such, it would probably be possible for a banned player to keep creating new characters to circumvent the ban. If we're actually supporting this functionality, this should probably be fixed, but I couldn't find anything that actually calls banPlayer anywhere within the project code, so I don't know how this works.

If anyone is familiar with any of the above functionality and its current status, please let me know!