summaryrefslogtreecommitdiff
path: root/src/net/manaserv
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-12-04 10:39:31 -0700
committerJared Adams <jaxad0127@gmail.com>2009-12-04 13:01:46 -0700
commit51fc0fa1fffda1da0a71f7248ca809bbc5b87620 (patch)
treeacf0b14d15587173b3503b2679d5b8d3aa2b8109 /src/net/manaserv
parent257fa6b93daa151dcaacf1f45f0111d6c4187d37 (diff)
downloadmana-51fc0fa1fffda1da0a71f7248ca809bbc5b87620.tar.gz
mana-51fc0fa1fffda1da0a71f7248ca809bbc5b87620.tar.bz2
mana-51fc0fa1fffda1da0a71f7248ca809bbc5b87620.tar.xz
mana-51fc0fa1fffda1da0a71f7248ca809bbc5b87620.zip
Register credentials information service
Diffstat (limited to 'src/net/manaserv')
-rw-r--r--src/net/manaserv/loginhandler.cpp61
-rw-r--r--src/net/manaserv/loginhandler.h14
-rw-r--r--src/net/manaserv/protocol.h7
3 files changed, 78 insertions, 4 deletions
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