summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Authenticator.cpp
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2017-08-25 14:43:18 +0200
committerAlexander Harkness <me@bearbin.net>2017-08-25 14:43:18 +0200
commitf4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7 (patch)
tree70139b1ad7ed221e4b75c3a9e247b337de68eb07 /src/Protocol/Authenticator.cpp
parentcompile.sh update. Fixed -d and -n, intelligent thread choice (#3960) (diff)
downloadcuberite-f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7.tar
cuberite-f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7.tar.gz
cuberite-f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7.tar.bz2
cuberite-f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7.tar.lz
cuberite-f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7.tar.xz
cuberite-f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7.tar.zst
cuberite-f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7.zip
Diffstat (limited to '')
-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);