From fc324fbff3580a0146994ab369b3e9967f0eb594 Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Sun, 9 Nov 2025 02:16:04 -0500 Subject: [PATCH] feat: implement login and authentication check methods in OverteClient class --- src/OverteClient.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/OverteClient.cpp b/src/OverteClient.cpp index c2709ba..4f41b96 100644 --- a/src/OverteClient.cpp +++ b/src/OverteClient.cpp @@ -121,6 +121,22 @@ static std::string generateUUID() { return ss.str(); } +bool OverteClient::login(const std::string& username, const std::string& password, const std::string& metaverseUrl) { + if (!m_auth) { + m_auth = std::make_unique(); + } + + bool success = m_auth->login(username, password, metaverseUrl); + if (success) { + m_username = username; + } + return success; +} + +bool OverteClient::isAuthenticated() const { + return m_auth && m_auth->isAuthenticated(); +} + bool OverteClient::connect() { // Generate session UUID m_sessionUUID = generateUUID(); @@ -128,10 +144,20 @@ bool OverteClient::connect() { // Check for authentication credentials from environment const char* usernameEnv = std::getenv("OVERTE_USERNAME"); - if (usernameEnv) m_username = usernameEnv; + const char* passwordEnv = std::getenv("OVERTE_PASSWORD"); + const char* metaverseEnv = std::getenv("OVERTE_METAVERSE"); - if (!m_username.empty()) { - std::cout << "[OverteClient] Username present (signature auth not yet implemented)" << std::endl; + if (usernameEnv && passwordEnv) { + std::string metaverseUrl = metaverseEnv ? metaverseEnv : "https://mv.overte.org"; + std::cout << "[OverteClient] Attempting login as " << usernameEnv << "..." << std::endl; + if (login(usernameEnv, passwordEnv, metaverseUrl)) { + std::cout << "[OverteClient] Successfully authenticated!" << std::endl; + } else { + std::cerr << "[OverteClient] Authentication failed, continuing as anonymous" << std::endl; + } + } else if (usernameEnv) { + m_username = usernameEnv; + std::cout << "[OverteClient] Username set (no password provided, signature auth not yet implemented)" << std::endl; } // Parse ws://host:port