mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 23:52:02 +08:00
Fix of login in internal browser
This commit is contained in:
parent
23cc50c9f5
commit
3e6b4ba443
@ -38,7 +38,7 @@ public:
|
|||||||
bool is_logged();
|
bool is_logged();
|
||||||
void do_login();
|
void do_login();
|
||||||
void do_logout();
|
void do_logout();
|
||||||
wxString get_login_redirect_url() { return m_communication->get_login_redirect_url(true); }
|
wxString get_login_redirect_url() { return m_communication->get_login_redirect_url(); }
|
||||||
|
|
||||||
void set_remember_session(bool remember);
|
void set_remember_session(bool remember);
|
||||||
void toggle_remember_session();
|
void toggle_remember_session();
|
||||||
|
@ -321,7 +321,8 @@ void UserAccountCommunication::on_uuid_map_success()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString UserAccountCommunication::get_login_redirect_url(bool internal) {
|
// Generates and stores Code Verifier - second call deletes previous one.
|
||||||
|
wxString UserAccountCommunication::get_login_redirect_url() {
|
||||||
auto& sc = Utils::ServiceConfig::instance();
|
auto& sc = Utils::ServiceConfig::instance();
|
||||||
const std::string AUTH_HOST = sc.account_url();
|
const std::string AUTH_HOST = sc.account_url();
|
||||||
const std::string CLIENT_ID = client_id();
|
const std::string CLIENT_ID = client_id();
|
||||||
@ -335,15 +336,12 @@ wxString UserAccountCommunication::get_login_redirect_url(bool internal) {
|
|||||||
BOOST_LOG_TRIVIAL(info) << "code challenge: " << code_challenge;
|
BOOST_LOG_TRIVIAL(info) << "code challenge: " << code_challenge;
|
||||||
|
|
||||||
wxString url = GUI::format_wxstr(L"%1%/o/authorize/?embed=1&client_id=%2%&response_type=code&code_challenge=%3%&code_challenge_method=S256&scope=basic_info&redirect_uri=%4%&language=%5%", AUTH_HOST, CLIENT_ID, code_challenge, REDIRECT_URI, language);
|
wxString url = GUI::format_wxstr(L"%1%/o/authorize/?embed=1&client_id=%2%&response_type=code&code_challenge=%3%&code_challenge_method=S256&scope=basic_info&redirect_uri=%4%&language=%5%", AUTH_HOST, CLIENT_ID, code_challenge, REDIRECT_URI, language);
|
||||||
if (!internal) {
|
|
||||||
url += L"&choose_account=1";
|
|
||||||
}
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
void UserAccountCommunication::login_redirect()
|
void UserAccountCommunication::login_redirect()
|
||||||
{
|
{
|
||||||
wxString url1 = get_login_redirect_url(true);
|
wxString url1 = get_login_redirect_url();
|
||||||
wxString url2 = get_login_redirect_url(false);
|
wxString url2 = url1 + L"&choose_account=1";
|
||||||
wxQueueEvent(m_evt_handler,new OpenPrusaAuthEvent(GUI::EVT_OPEN_PRUSAAUTH, {std::move(url1), std::move(url2)}));
|
wxQueueEvent(m_evt_handler,new OpenPrusaAuthEvent(GUI::EVT_OPEN_PRUSAAUTH, {std::move(url1), std::move(url2)}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,8 @@ public:
|
|||||||
void do_login();
|
void do_login();
|
||||||
void do_logout();
|
void do_logout();
|
||||||
void do_clear();
|
void do_clear();
|
||||||
wxString get_login_redirect_url(bool internal);
|
// Generates and stores Code Verifier - second call deletes previous one.
|
||||||
|
wxString get_login_redirect_url();
|
||||||
// Trigger function starts various remote operations
|
// Trigger function starts various remote operations
|
||||||
void enqueue_connect_status_action();
|
void enqueue_connect_status_action();
|
||||||
void enqueue_connect_printer_models_action();
|
void enqueue_connect_printer_models_action();
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "slic3r/GUI/format.hpp"
|
#include "slic3r/GUI/format.hpp"
|
||||||
#include "slic3r/GUI/WebView.hpp"
|
#include "slic3r/GUI/WebView.hpp"
|
||||||
#include "slic3r/GUI/WebViewPlatformUtils.hpp"
|
#include "slic3r/GUI/WebViewPlatformUtils.hpp"
|
||||||
|
#include "slic3r/Utils/ServiceConfig.hpp"
|
||||||
|
|
||||||
#include "slic3r/GUI/MsgDialog.hpp"
|
#include "slic3r/GUI/MsgDialog.hpp"
|
||||||
#include "slic3r/GUI/Field.hpp"
|
#include "slic3r/GUI/Field.hpp"
|
||||||
@ -1377,15 +1378,18 @@ LoginWebViewDialog::LoginWebViewDialog(wxWindow *parent, std::string &ret_val, c
|
|||||||
}
|
}
|
||||||
void LoginWebViewDialog::on_navigation_request(wxWebViewEvent &evt)
|
void LoginWebViewDialog::on_navigation_request(wxWebViewEvent &evt)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " " << evt.GetURL();
|
|
||||||
wxString url = evt.GetURL();
|
wxString url = evt.GetURL();
|
||||||
if (url.starts_with(L"prusaslicer")) {
|
if (url.starts_with(L"prusaslicer")) {
|
||||||
evt.Veto();
|
evt.Veto();
|
||||||
m_ret_val = into_u8(url);
|
m_ret_val = into_u8(url);
|
||||||
EndModal(wxID_OK);
|
EndModal(wxID_OK);
|
||||||
} else if (!url.starts_with(L"https://account.prusa3d.com") && url.starts_with(L"http")) {
|
} else if (url.starts_with(L"http")) {
|
||||||
m_ret_val = GUI::into_u8(url);
|
auto& sc = Utils::ServiceConfig::instance();
|
||||||
EndModal(wxID_EXECUTE);
|
if (!url.starts_with(GUI::from_u8(sc.account_url()))) {
|
||||||
|
m_ret_val = GUI::into_u8(url);
|
||||||
|
EndModal(wxID_EXECUTE);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void LoginWebViewDialog::on_dpi_changed(const wxRect &suggested_rect)
|
void LoginWebViewDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user