summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Authenticator.cpp
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2017-08-27 08:13:40 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2017-08-27 08:13:40 +0200
commite274d0dd8a6eefeb6e84272ffd09ac55b2c08900 (patch)
tree377f52ed5738810c157e631ec31f626fbe5acef6 /src/Protocol/Authenticator.cpp
parentd (diff)
parentImplement anvil chunk sparsing (diff)
downloadcuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar
cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar.gz
cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar.bz2
cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar.lz
cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar.xz
cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar.zst
cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.zip
Diffstat (limited to 'src/Protocol/Authenticator.cpp')
-rw-r--r--src/Protocol/Authenticator.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp
index 12e963143..d46127d34 100644
--- a/src/Protocol/Authenticator.cpp
+++ b/src/Protocol/Authenticator.cpp
@@ -6,6 +6,7 @@
#include "../Root.h"
#include "../Server.h"
#include "../ClientHandle.h"
+#include "../UUID.h"
#include "../IniFile.h"
#include "json/json.h"
@@ -119,11 +120,11 @@ void cAuthenticator::Execute(void)
Lock.Unlock();
AString NewUserName = UserName;
- AString UUID;
+ cUUID UUID;
Json::Value Properties;
if (AuthWithYggdrasil(NewUserName, ServerID, UUID, Properties))
{
- LOGINFO("User %s authenticated with UUID %s", NewUserName.c_str(), UUID.c_str());
+ LOGINFO("User %s authenticated with UUID %s", NewUserName.c_str(), UUID.ToShortString().c_str());
cRoot::Get()->AuthenticateUser(ClientID, NewUserName, UUID, Properties);
}
else
@@ -137,7 +138,7 @@ void cAuthenticator::Execute(void)
-bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID, Json::Value & a_Properties)
+bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, cUUID & a_UUID, Json::Value & a_Properties)
{
LOGD("Trying to authenticate user %s", a_UserName.c_str());
@@ -192,8 +193,12 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
return false;
}
a_UserName = root.get("name", "Unknown").asString();
- a_UUID = cMojangAPI::MakeUUIDShort(root.get("id", "").asString());
a_Properties = root["properties"];
+ if (!a_UUID.FromString(root.get("id", "").asString()))
+ {
+ LOGWARNING("cAuthenticator: Recieved invalid UUID format");
+ return false;
+ }
// Store the player's profile in the MojangAPI caches:
cRoot::Get()->GetMojangAPI().AddPlayerProfile(a_UserName, a_UUID, a_Properties);