From 28721a9742f890cacd98000dc1d9a0dfc5ba2a0c Mon Sep 17 00:00:00 2001 From: RektInator Date: Thu, 3 Oct 2019 09:16:26 +0200 Subject: [PATCH] [Auth] Generate new key when key is invalid. --- src/Components/Modules/Auth.cpp | 16 +++++++++++----- src/Components/Modules/Auth.hpp | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Components/Modules/Auth.cpp b/src/Components/Modules/Auth.cpp index 67b622e0..9e47b0fb 100644 --- a/src/Components/Modules/Auth.cpp +++ b/src/Components/Modules/Auth.cpp @@ -70,7 +70,8 @@ namespace Components if (std::find(Auth::BannedUids.begin(), Auth::BannedUids.end(), Steam::SteamUser()->GetSteamID().bits) != Auth::BannedUids.end()) { - Logger::SoftError("Your online profile is invalid. Delete your players folder and restart ^2IW4x^7."); + Auth::GenerateKey(); + Logger::SoftError("Your online profile is invalid. A new key has been generated."); return; } @@ -284,6 +285,14 @@ namespace Components } } + void Auth::GenerateKey() + { + Auth::GuidToken.clear(); + Auth::ComputeToken.clear(); + Auth::GuidKey = Utils::Cryptography::ECC::GenerateKey(512); + Auth::StoreKey(); + } + void Auth::LoadKey(bool force) { if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled()) return; @@ -303,10 +312,7 @@ namespace Components if (!Auth::GuidKey.isValid()) { - Auth::GuidToken.clear(); - Auth::ComputeToken.clear(); - Auth::GuidKey = Utils::Cryptography::ECC::GenerateKey(512); - Auth::StoreKey(); + Auth::GenerateKey(); } } diff --git a/src/Components/Modules/Auth.hpp b/src/Components/Modules/Auth.hpp index 0d070f3a..84d35fca 100644 --- a/src/Components/Modules/Auth.hpp +++ b/src/Components/Modules/Auth.hpp @@ -13,6 +13,8 @@ namespace Components static void StoreKey(); static void LoadKey(bool force = false); + static void GenerateKey(); + static unsigned __int64 GetKeyHash(); static unsigned __int64 GetKeyHash(const std::string& key);