From 08a19a3fc8e181bf04a7a2316824afaea7e20cd0 Mon Sep 17 00:00:00 2001 From: PilotMatt <55398315+PilotMatt@users.noreply.github.com> Date: Tue, 13 Feb 2024 23:23:29 -0500 Subject: [PATCH] checking --- src/slic3r/Utils/PrintagoServer.cpp | 10 +++++++--- src/slic3r/Utils/PrintagoServer.hpp | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/slic3r/Utils/PrintagoServer.cpp b/src/slic3r/Utils/PrintagoServer.cpp index 030ad55b7c6..64cd6312dda 100644 --- a/src/slic3r/Utils/PrintagoServer.cpp +++ b/src/slic3r/Utils/PrintagoServer.cpp @@ -457,12 +457,15 @@ bool PrintagoDirector::ProcessPrintagoCommand(const PrintagoCommand& cmd) if (!commandType.compare("meta")) { if (!action.compare("init")) { std::string token = parameters["token"]; + std::string url_base = parameters.find("url_base") != parameters.end() && !parameters["url_base"].empty() ? + Http::url_decode(parameters["url_base"]) : + "http://localhost:3000"; if (token.empty()) { PostErrorMessage("", "", cmd.GetOriginalCommand(), "Unauthorized: No Token"); return false; } - if (ValidateToken(token)) { + if (ValidateToken(token, url_base)) { server->get_session()->set_authorized(true); actionDetail = "Authorized"; } else { @@ -1296,9 +1299,10 @@ void PrintagoDirector::OnPrintJobSent(wxString printerId, bool success) PostSuccessMessage(PBJob::printerId, "start_print_bbl", PBJob::command, wxString::Format("print sent to: %s", printerId)); } -bool PrintagoDirector::ValidateToken(const std::string& token) +bool PrintagoDirector::ValidateToken(const std::string& token, const std::string& url_base) { - std::string url = "http://localhost:3000/api/slicer-tokens/" + token; + + std::string url = url_base + "/api/slicer-tokens/" + token; bool isValid = false; // Perform the HTTP GET request synchronously diff --git a/src/slic3r/Utils/PrintagoServer.hpp b/src/slic3r/Utils/PrintagoServer.hpp index e3efc7acfc3..acdb20042c7 100644 --- a/src/slic3r/Utils/PrintagoServer.hpp +++ b/src/slic3r/Utils/PrintagoServer.hpp @@ -226,7 +226,7 @@ class PrintagoDirector bool SavePrintagoFile(const wxString url, wxFileName& localPath); bool DownloadFileFromURL(const wxString url, const wxFileName& localPath); - bool ValidateToken(const std::string& token); + bool ValidateToken(const std::string& token, const std::string& url_base); }; //``````````````````````````````````````````````````