diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index f2c306d28c..d5f78393e9 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -4846,18 +4846,23 @@ void GUI_App::on_http_error(wxCommandEvent &evt) if (status == 401) { if (m_agent) { if (m_agent->is_user_login(provider)) { - BOOST_LOG_TRIVIAL(warning) << "logout: http error 401."; - this->request_user_logout(provider); + if (std::chrono::steady_clock::now() - m_last_401_error_time > 30s) { + BOOST_LOG_TRIVIAL(warning) << "logout: http error 401."; + this->request_user_logout(provider); - if (!m_show_http_error_msgdlg) { - MessageDialog msg_dlg(nullptr, _L("Login information expired. Please login again."), "", wxAPPLY | wxOK); - m_show_http_error_msgdlg = true; - auto modal_result = msg_dlg.ShowModal(); - if (modal_result == wxOK || modal_result == wxCLOSE) { - m_show_http_error_msgdlg = false; - return; + if (!m_show_http_error_msgdlg) { + MessageDialog msg_dlg(nullptr, _L("Login information expired. Please login again."), "", wxAPPLY | wxOK); + m_show_http_error_msgdlg = true; + auto modal_result = msg_dlg.ShowModal(); + if (modal_result == wxOK || modal_result == wxCLOSE) { + m_show_http_error_msgdlg = false; + return; + } } + } else { + BOOST_LOG_TRIVIAL(warning) << "401 encountered within grace period, suppressing logout"; } + m_last_401_error_time = std::chrono::steady_clock::now(); } } return; @@ -4931,6 +4936,10 @@ void GUI_App::on_user_login_handle(wxCommandEvent &evt) std::string provider = evt.GetString().ToStdString(); if (provider.empty()) provider = ORCA_CLOUD_PROVIDER; + // Reset 401 grace period so transient token-propagation 401s + // during login warmup don't trigger immediate logout. + m_last_401_error_time = std::chrono::steady_clock::now(); + m_agent->connect_server(); // get machine list DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 7244425cfb..6a5dd0315d 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -326,6 +326,7 @@ private: bool m_adding_script_handler { false }; bool m_side_popup_status{false}; bool m_show_http_error_msgdlg{false}; + std::chrono::steady_clock::time_point m_last_401_error_time; bool m_show_error_msgdlg{false}; wxString m_info_dialog_content; HttpServer m_http_server;