From 6fc502c3c9c4b1970fc0dae88cda88c20730dc1e Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Sun, 24 Jan 2016 12:04:14 +0100 Subject: [PATCH] Slack: redirect to https instead of http --- libtransport/OAuth2.cpp | 12 ++++++++++++ .../src/frontends/slack/SlackUserRegistration.cpp | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libtransport/OAuth2.cpp b/libtransport/OAuth2.cpp index bdbb56a8..6b3841c7 100644 --- a/libtransport/OAuth2.cpp +++ b/libtransport/OAuth2.cpp @@ -84,15 +84,27 @@ std::string OAuth2::requestToken(const std::string &code, std::string &token) { rapidjson::Document resp; HTTPRequest req(HTTPRequest::Get, url); if (!req.execute(resp)) { + LOG4CXX_ERROR(logger, url); + LOG4CXX_ERROR(logger, req.getError()); return req.getError(); } rapidjson::Value& access_token = resp["access_token"]; if (!access_token.IsString()) { + LOG4CXX_ERROR(logger, "No 'access_token' object in the reply."); + LOG4CXX_ERROR(logger, url); + LOG4CXX_ERROR(logger, req.getRawData()); return "No 'access_token' object in the reply."; } token = access_token.GetString(); + if (token.empty()) { + LOG4CXX_ERROR(logger, "Empty 'access_token' object in the reply."); + LOG4CXX_ERROR(logger, url); + LOG4CXX_ERROR(logger, req.getRawData()); + return "Empty 'access_token' object in the reply."; + } + return ""; } diff --git a/spectrum/src/frontends/slack/SlackUserRegistration.cpp b/spectrum/src/frontends/slack/SlackUserRegistration.cpp index d5d868bf..60134dbc 100644 --- a/spectrum/src/frontends/slack/SlackUserRegistration.cpp +++ b/spectrum/src/frontends/slack/SlackUserRegistration.cpp @@ -62,7 +62,7 @@ SlackUserRegistration::~SlackUserRegistration(){ } std::string SlackUserRegistration::createOAuth2URL(const std::vector &args) { - std::string redirect_url = "http://slack.spectrum.im/oauth2/" + CONFIG_STRING(m_config, "service.jid"); + std::string redirect_url = "https://slack.spectrum.im/oauth2/" + CONFIG_STRING(m_config, "service.jid"); OAuth2 *oauth2 = new OAuth2(CONFIG_STRING_DEFAULTED(m_config, "service.client_id",""), CONFIG_STRING_DEFAULTED(m_config, "service.client_secret",""), "https://slack.com/oauth/authorize",