From 93df0ce3841f23c74f3501c84fbc5b0c5975ea1b Mon Sep 17 00:00:00 2001 From: David Kocik Date: Tue, 5 Mar 2024 15:41:57 +0100 Subject: [PATCH] Temporary sending session id instead of access key --- src/slic3r/GUI/UserAccount.cpp | 5 +++++ src/slic3r/GUI/UserAccount.hpp | 1 + src/slic3r/GUI/UserAccountCommunication.cpp | 8 ++++++++ src/slic3r/GUI/UserAccountCommunication.hpp | 1 + src/slic3r/GUI/WebViewDialog.cpp | 6 ++++-- 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/UserAccount.cpp b/src/slic3r/GUI/UserAccount.cpp index af04a5fc87..3455935cee 100644 --- a/src/slic3r/GUI/UserAccount.cpp +++ b/src/slic3r/GUI/UserAccount.cpp @@ -67,6 +67,11 @@ std::string UserAccount::get_access_token() return m_communication->get_access_token(); } +std::string UserAccount::get_shared_session_key() +{ + return m_communication->get_shared_session_key(); +} + boost::filesystem::path UserAccount::get_avatar_path(bool logged) const { if (logged) { diff --git a/src/slic3r/GUI/UserAccount.hpp b/src/slic3r/GUI/UserAccount.hpp index 982cf9ff02..89ce88621b 100644 --- a/src/slic3r/GUI/UserAccount.hpp +++ b/src/slic3r/GUI/UserAccount.hpp @@ -59,6 +59,7 @@ public: std::string get_username() const { return m_username; } std::string get_access_token(); + std::string get_shared_session_key(); const ConnectPrinterStateMap& get_printer_state_map() const { return m_printer_map; } boost::filesystem::path get_avatar_path(bool logged) const; diff --git a/src/slic3r/GUI/UserAccountCommunication.cpp b/src/slic3r/GUI/UserAccountCommunication.cpp index 07a5419886..7de272b6e8 100644 --- a/src/slic3r/GUI/UserAccountCommunication.cpp +++ b/src/slic3r/GUI/UserAccountCommunication.cpp @@ -201,6 +201,14 @@ std::string UserAccountCommunication::get_access_token() } } +std::string UserAccountCommunication::get_shared_session_key() +{ + { + std::lock_guard lock(m_session_mutex); + return m_session->get_shared_session_key(); + } +} + void UserAccountCommunication::set_polling_enabled(bool enabled) { { diff --git a/src/slic3r/GUI/UserAccountCommunication.hpp b/src/slic3r/GUI/UserAccountCommunication.hpp index 621293588e..db6eb05168 100644 --- a/src/slic3r/GUI/UserAccountCommunication.hpp +++ b/src/slic3r/GUI/UserAccountCommunication.hpp @@ -60,6 +60,7 @@ public: std::string get_username() const { return m_username; } std::string get_access_token(); + std::string get_shared_session_key(); void set_polling_enabled(bool enabled); diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index 4ad611cda7..657e840e93 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -500,8 +500,10 @@ void ConnectRequestHandler::on_request_config() language?: ConnectLanguage; sessionId?: string; */ - const std::string token = wxGetApp().plater()->get_user_account()->get_access_token(); - const std::string init_options = GUI::format("{\"accessToken\": \"%1%\" }", token); + //const std::string token = wxGetApp().plater()->get_user_account()->get_access_token(); + //const std::string init_options = GUI::format("{\"accessToken\": \"%1%\" }", token); + const std::string token = wxGetApp().plater()->get_user_account()->get_shared_session_key(); + const std::string init_options = GUI::format("{\"sessionId\": \"%1%\" }", token); wxString script = GUI::format_wxstr("window._prusaConnect_v1.init(%1%)", init_options); run_script_bridge(script); }