diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/loginhandler.cpp | 6 | ||||
-rw-r--r-- | src/net/ea/loginhandler.h | 2 | ||||
-rw-r--r-- | src/net/logindata.h | 2 | ||||
-rw-r--r-- | src/net/loginhandler.h | 2 | ||||
-rw-r--r-- | src/net/manaserv/loginhandler.cpp | 61 | ||||
-rw-r--r-- | src/net/manaserv/loginhandler.h | 14 | ||||
-rw-r--r-- | src/net/manaserv/protocol.h | 7 |
7 files changed, 90 insertions, 4 deletions
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 2c6ac1d2..e27eccf8 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -209,6 +209,12 @@ void LoginHandler::disconnect() mNetwork->disconnect(); } +void LoginHandler::getRegistrationDetails() +{ + // Not supported, so move on + state = STATE_REGISTER; +} + void LoginHandler::loginAccount(LoginData *loginData) { sendLoginRegister(loginData->username, loginData->password); diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h index ac3bf4f4..16c5fe95 100644 --- a/src/net/ea/loginhandler.h +++ b/src/net/ea/loginhandler.h @@ -49,6 +49,8 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler int supportedOptionalActions() const { return SetGenderOnRegister; } + void getRegistrationDetails(); + void loginAccount(LoginData *loginData); void logout(); diff --git a/src/net/logindata.h b/src/net/logindata.h index 4f592f7d..8df06171 100644 --- a/src/net/logindata.h +++ b/src/net/logindata.h @@ -35,6 +35,7 @@ struct LoginData std::string updateHost; std::string email; + std::string captchaResponse; Gender gender; @@ -48,6 +49,7 @@ struct LoginData newPassword.clear(); updateHost.clear(); email.clear(); + captchaResponse.clear(); gender = GENDER_UNSPECIFIED; } }; diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h index 89af9120..6d42088d 100644 --- a/src/net/loginhandler.h +++ b/src/net/loginhandler.h @@ -63,6 +63,8 @@ class LoginHandler */ virtual int supportedOptionalActions() const = 0; + virtual void getRegistrationDetails() = 0; + virtual unsigned int getMinUserNameLength() const { return 4; }; virtual unsigned int getMaxUserNameLength() const { return 25; }; diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp index ff8d142d..bd29d1d9 100644 --- a/src/net/manaserv/loginhandler.cpp +++ b/src/net/manaserv/loginhandler.cpp @@ -50,6 +50,7 @@ LoginHandler::LoginHandler() APMSG_EMAIL_CHANGE_RESPONSE, APMSG_LOGOUT_RESPONSE, APMSG_UNREGISTER_RESPONSE, + APMSG_REGISTER_INFO_RESPONSE, 0 }; handledMessages = _messages; @@ -206,6 +207,35 @@ void LoginHandler::handleMessage(Net::MessageIn &msg) } } break; + + case APMSG_REGISTER_INFO_RESPONSE: + { + int allowed = msg.readInt8(); + + if (allowed) + { + mMinUserNameLength = msg.readInt8(); + mMaxUserNameLength = msg.readInt8(); + mMinPasswordLength = msg.readInt8(); + mMaxPasswordLength = msg.readInt8(); + std::string captchaURL = msg.readString(); + std::string captchaInstructions = msg.readString(); + + printf("%s: %s\n", captchaURL.c_str(), captchaInstructions.c_str()); + + state = STATE_REGISTER; + } + else + { + errorMessage = msg.readString(); + + if (errorMessage.empty()) + errorMessage = _("Client registration is not allowed. " + "Please contact server administration."); + state = STATE_LOGIN_ERROR; + } + } + break; } } @@ -270,6 +300,10 @@ void LoginHandler::handleRegisterResponse(Net::MessageIn &msg) case REGISTER_EXISTS_EMAIL: errorMessage = _("Email address already exists."); break; + case REGISTER_FAILED_CAPTCHA: + errorMessage = _("You took too long with the captcha or your " + "response was incorrect."); + break; default: errorMessage = _("Unknown error."); break; @@ -307,6 +341,32 @@ void LoginHandler::disconnect() } } +void LoginHandler::getRegistrationDetails() +{ + MessageOut msg(PAMSG_REQUEST_REGISTER_INFO); + accountServerConnection->send(msg); +} + +unsigned int LoginHandler::getMinUserNameLength() const +{ + return mMinUserNameLength; +} + +unsigned int LoginHandler::getMaxUserNameLength() const +{ + return mMaxUserNameLength; +} + +unsigned int LoginHandler::getMinPasswordLength() const +{ + return mMinPasswordLength; +} + +unsigned int LoginHandler::getMaxPasswordLength() const +{ + return mMaxPasswordLength; +} + void LoginHandler::loginAccount(LoginData *loginData) { mLoginData = loginData; @@ -366,6 +426,7 @@ void LoginHandler::registerAccount(LoginData *loginData) // This is the only time we send a clear password. msg.writeString(loginData->password); msg.writeString(loginData->email); + msg.writeString(loginData->captchaResponse); accountServerConnection->send(msg); } diff --git a/src/net/manaserv/loginhandler.h b/src/net/manaserv/loginhandler.h index 1a929c96..75e2daf3 100644 --- a/src/net/manaserv/loginhandler.h +++ b/src/net/manaserv/loginhandler.h @@ -47,9 +47,15 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler int supportedOptionalActions() const { return Unregister | ChangeEmail | SetEmailOnRegister; } - unsigned int getMaxUserNameLength() const { return 15; }; + void getRegistrationDetails(); - unsigned int getMinPasswordLength() const { return 6; }; + unsigned int getMinUserNameLength() const; + + unsigned int getMaxUserNameLength() const; + + unsigned int getMinPasswordLength() const; + + unsigned int getMaxPasswordLength() const; void loginAccount(LoginData *loginData); @@ -79,6 +85,10 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler void readUpdateHost(Net::MessageIn &msg); LoginData *mLoginData; + unsigned int mMinUserNameLength; + unsigned int mMaxUserNameLength; + unsigned int mMinPasswordLength; + unsigned int mMaxPasswordLength; }; } // namespace ManaServ diff --git a/src/net/manaserv/protocol.h b/src/net/manaserv/protocol.h index d1ff3f73..fe38f35c 100644 --- a/src/net/manaserv/protocol.h +++ b/src/net/manaserv/protocol.h @@ -40,10 +40,12 @@ */ enum { // Login/Register - PAMSG_REGISTER = 0x0000, // L version, S username, S password, S email + PAMSG_REGISTER = 0x0000, // L version, S username, S password, S email, S captcha response APMSG_REGISTER_RESPONSE = 0x0002, // B error [, S updatehost] PAMSG_UNREGISTER = 0x0003, // - APMSG_UNREGISTER_RESPONSE = 0x0004, // B error + PAMSG_REQUEST_REGISTER_INFO = 0x0005, // + APMSG_REGISTER_INFO_RESPONSE = 0x0006, // B byte registrationAllowed, byte minEmailLength, byte maxEmailLength, byte minNameLength, byte maxNameLength, byte minPasswordLength, byte maxPasswordLength, string captchaURL, string captchaInstructions PAMSG_LOGIN = 0x0010, // L version, S username, S password APMSG_LOGIN_RESPONSE = 0x0012, // B error [, S updatehost] PAMSG_LOGOUT = 0x0013, // - @@ -238,7 +240,8 @@ enum { enum { REGISTER_INVALID_VERSION = 0x40, // the user is using an incompatible protocol REGISTER_EXISTS_USERNAME, // there already is an account with this username - REGISTER_EXISTS_EMAIL // there already is an account with this email address + REGISTER_EXISTS_EMAIL, // there already is an account with this email address + REGISTER_FAILED_CAPTCHA // captcha respose is bad }; // Character creation specific return values |