summary refs log tree commit diff
path: root/src/SSOHandler.cpp
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2021-09-17 23:06:03 +0000
committerGitHub <noreply@github.com>2021-09-17 23:06:03 +0000
commitd1c8149d07b6c4be63cec581e5a7f5108ce56058 (patch)
tree32b92340908a9374214ec7b84c1fac7ea338f56d /src/SSOHandler.cpp
parentMerge pull request #728 from Thulinma/goto (diff)
parentChange indentation to 4 spaces (diff)
downloadnheko-d1c8149d07b6c4be63cec581e5a7f5108ce56058.tar.xz
Merge pull request #729 from Nheko-Reborn/reformat
Change indentation to 4 spaces
Diffstat (limited to 'src/SSOHandler.cpp')
-rw-r--r--src/SSOHandler.cpp64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/SSOHandler.cpp b/src/SSOHandler.cpp

index 8fd0828c..a6f7ba11 100644 --- a/src/SSOHandler.cpp +++ b/src/SSOHandler.cpp
@@ -12,46 +12,46 @@ SSOHandler::SSOHandler(QObject *) { - QTimer::singleShot(120000, this, &SSOHandler::ssoFailed); - - using namespace httplib; - - svr.set_logger([](const Request &req, const Response &res) { - nhlog::net()->info("req: {}, res: {}", req.path, res.status); - }); - - svr.Get("/sso", [this](const Request &req, Response &res) { - if (req.has_param("loginToken")) { - auto val = req.get_param_value("loginToken"); - res.set_content("SSO success", "text/plain"); - emit ssoSuccess(val); - } else { - res.set_content("Missing loginToken for SSO login!", "text/plain"); - emit ssoFailed(); - } - }); - - std::thread t([this]() { - this->port = svr.bind_to_any_port("localhost"); - svr.listen_after_bind(); - }); - t.detach(); - - while (!svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + QTimer::singleShot(120000, this, &SSOHandler::ssoFailed); + + using namespace httplib; + + svr.set_logger([](const Request &req, const Response &res) { + nhlog::net()->info("req: {}, res: {}", req.path, res.status); + }); + + svr.Get("/sso", [this](const Request &req, Response &res) { + if (req.has_param("loginToken")) { + auto val = req.get_param_value("loginToken"); + res.set_content("SSO success", "text/plain"); + emit ssoSuccess(val); + } else { + res.set_content("Missing loginToken for SSO login!", "text/plain"); + emit ssoFailed(); } + }); + + std::thread t([this]() { + this->port = svr.bind_to_any_port("localhost"); + svr.listen_after_bind(); + }); + t.detach(); + + while (!svr.is_running()) { + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + } } SSOHandler::~SSOHandler() { - svr.stop(); - while (svr.is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } + svr.stop(); + while (svr.is_running()) { + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + } } std::string SSOHandler::url() const { - return "http://localhost:" + std::to_string(port) + "/sso"; + return "http://localhost:" + std::to_string(port) + "/sso"; }