Changeset - b88294238340
[Not reviewed]
0 2 0
Jan Kaluza - 10 years ago 2016-01-24 11:48:40
jkaluza@redhat.com
SlackUserRegistration: show raw data when team domain cannot be found in the response
2 files changed with 5 insertions and 0 deletions:
0 comments (0 inline, 0 general)
include/transport/HTTPRequest.h
Show inline comments
 
@@ -23,24 +23,27 @@ class HTTPRequest : public Thread {
 

	
 
		virtual ~HTTPRequest() {
 
			if(curlhandle) {
 
				curl_easy_cleanup(curlhandle);
 
				curlhandle = NULL;
 
			}
 
		}
 

	
 
		void setProxy(std::string, std::string, std::string, std::string);
 
		bool execute();
 
		bool execute(rapidjson::Document &json);
 
		std::string getError() {return std::string(curl_errorbuffer);}
 
		const std::string &getRawData() {
 
			return m_data;
 
		}
 

	
 
		void run();
 
		void finalize();
 

	
 
		boost::signal<void ()> onRequestFinished;
 

	
 
	private:
 
		bool init();
 
		bool GET(std::string url, std::string &output);
 
		bool GET(std::string url, rapidjson::Document &json);
 

	
 

	
spectrum/src/frontends/slack/SlackUserRegistration.cpp
Show inline comments
 
@@ -81,30 +81,32 @@ std::string SlackUserRegistration::getTeamDomain(const std::string &token) {
 
	std::string url = "https://slack.com/api/team.info?token=" + Util::urlencode(token);
 

	
 
	rapidjson::Document resp;
 
	HTTPRequest req(HTTPRequest::Get, url);
 
	if (!req.execute(resp)) {
 
		LOG4CXX_ERROR(logger, req.getError());
 
		return "";
 
	}
 

	
 
	rapidjson::Value &team = resp["team"];
 
	if (!team.IsObject()) {
 
		LOG4CXX_ERROR(logger, "No 'team' object in the reply.");
 
		LOG4CXX_ERROR(logger, req.getRawData());
 
		return "";
 
	}
 

	
 
	rapidjson::Value &domain = team["domain"];
 
	if (!domain.IsString()) {
 
		LOG4CXX_ERROR(logger, "No 'domain' string in the reply.");
 
		LOG4CXX_ERROR(logger, req.getRawData());
 
		return "";
 
	}
 

	
 
	return domain.GetString();
 
}
 

	
 
std::string SlackUserRegistration::handleOAuth2Code(const std::string &code, const std::string &state) {
 
	OAuth2 *oauth2 = NULL;
 
	std::string token;
 
	std::vector<std::string> data;
 

	
 
	if (state == "use_bot_token") {
0 comments (0 inline, 0 general)