Changeset - bff117e4ef23
[Not reviewed]
0 5 0
Jan Kaluza - 9 years ago 2016-02-19 12:51:17
jkaluza@redhat.com
Slack: For IRC allow registering without providing account name/password
5 files changed with 42 insertions and 13 deletions:
0 comments (0 inline, 0 general)
libtransport/Config.cpp
Show inline comments
 
@@ -104,6 +104,7 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description
 
		("service.vip_only", value<bool>()->default_value(false), "")
 
		("service.vip_message", value<std::string>()->default_value(""), "")
 
		("service.reconnect_all_users", value<bool>()->default_value(false), "")
 
		("service.frontend", value<std::string>()->default_value("xmpp"), "")
 
		("service.web_directory", value<std::string>()->default_value(""), "Full path to directory used to save files to which the links are sent to users.")
 
		("service.web_url", value<std::string>()->default_value(""), "URL on which files in web_directory are accessible.")
 
		("vhosts.vhost", value<std::vector<std::string> >()->multitoken(), "")
 
@@ -113,7 +114,8 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description
 
		("registration.enable_public_registration", value<bool>()->default_value(true), "True if users should be able to register.")
 
		("registration.language", value<std::string>()->default_value("en"), "Default language for registration form")
 
		("registration.instructions", value<std::string>()->default_value("Enter your legacy network username and password."), "Instructions showed to user in registration form")
 
		("registration.username_label", value<std::string>()->default_value("Legacy network username:"), "Label for username field")
 
		("registration.username_label", value<std::string>()->default_value("3rd-party network username"), "Label for username field")
 
		("registration.password_label", value<std::string>()->default_value("3rd-party network password"), "Label for password field")
 
		("registration.username_mask", value<std::string>()->default_value(""), "Username mask")
 
		("registration.allowed_usernames", value<std::string>()->default_value(""), "Allowed usernames")
 
		("registration.auto_register", value<bool>()->default_value(false), "Register new user automatically when the presence arrives.")
spectrum/src/frontends/slack/SlackFrontend.cpp
Show inline comments
 
@@ -123,7 +123,12 @@ std::string SlackFrontend::getOAuth2URL(const std::vector<std::string> &args) {
 
}
 

	
 
std::string SlackFrontend::getRegistrationFields() {
 
	return "Main Slack channel\n3rd-party network username\n3rd-party network password";
 
	std::string fields = "Main Slack channel";
 
	if (CONFIG_BOOL(m_config, "registration.needRegistration")) {
 
		fields += "\n" + CONFIG_STRING(m_config, "registration.username_label") + "\n";
 
		fields += CONFIG_STRING(m_config, "registration.password_label");
 
	}
 
	return fields;
 
}
 

	
 
bool SlackFrontend::handleAdminMessage(Swift::Message::ref message) {
spectrum_manager/src/APIServer.cpp
Show inline comments
 
@@ -256,6 +256,18 @@ void APIServer::serve_instances_register(Server *server, Server::session *sessio
 
	std::string uin = get_http_var(hm, "uin");
 
	std::string password = get_http_var(hm, "password");
 

	
 
	// For some networks like IRC, there is no registration.
 
	// We detect such networks according to registration_fields and use
 
	// "unknown" uin for them.
 
	if (uin.empty()) {
 
		std::string response = server->send_command(instance, "registration_fields");
 
		std::vector<std::string> fields;
 
		boost::split(fields, response, boost::is_any_of("\n"));
 
		if (fields.size() == 1) {
 
			uin = "unknown";
 
		}
 
	}
 

	
 
	if (jid.empty() || uin.empty()) {
 
		send_ack(conn, true, "Insufficient data.");
 
	}
 
@@ -363,8 +375,7 @@ void APIServer::serve_instances_register_form(Server *server, Server::session *s
 
	std::vector<std::string> fields;
 
	boost::split(fields, response, boost::is_any_of("\n"));
 

	
 
	if (fields.size() < 3) {
 
		fields.clear();
 
	if (fields.empty()) {
 
		fields.push_back("Jabber ID");
 
		fields.push_back("3rd-party network username");
 
		fields.push_back("3rd-party network password");
 
@@ -374,8 +385,8 @@ void APIServer::serve_instances_register_form(Server *server, Server::session *s
 
	json.SetObject();
 
	json.AddMember("error", 0, json.GetAllocator());
 
	json.AddMember("username_label", fields[0].c_str(), json.GetAllocator());
 
	json.AddMember("legacy_username_label", fields[1].c_str(), json.GetAllocator());
 
	json.AddMember("password_label", fields[2].c_str(), json.GetAllocator());
 
	json.AddMember("legacy_username_label", fields.size() >= 2 ? fields[1].c_str() : "", json.GetAllocator());
 
	json.AddMember("password_label", fields.size() >= 3 ? fields[2].c_str() : "", json.GetAllocator());
 
	send_json(conn, json);
 
}
 

	
spectrum_manager/src/html/instances/register.shtml
Show inline comments
 
@@ -9,11 +9,11 @@
 
	<span id="jid_desc"></span> 
 
	<input type="text" id="jid" name="jid" placeholder=""></textarea> 
 
</label> 
 
<label> 
 
<label id="uin_label"> 
 
	<span id="uin_desc"></span> 
 
	<input type="text" id="uin" name="uin" placeholder=""></textarea> 
 
</label> 
 
<label><span id="password_desc"></span> 
 
<label id="password_label"><span id="password_desc"></span> 
 
	<input type="password" id="password" name="password" placeholder=""></textarea> 
 
</label> 
 
<label> 
spectrum_manager/src/html/js/app.js
Show inline comments
 
@@ -185,12 +185,23 @@ function fill_instances_register_form() {
 
	
 
	$.get($.cookie("base_location") + "api/v1/instances/register_form/" + query.id, function(data) {
 
		$("#jid_desc").html(data.username_label + ":");
 
		$("#uin_desc").html(data.legacy_username_label + ":");
 
		$("#password_desc").html(data.password_label + ":");
 

	
 
		$("#jid").attr("placeholder", data.username_label);
 
		$("#uin").attr("placeholder", data.legacy_username_label);
 
		$("#password").attr("placeholder", data.password_label);
 

	
 
		if (data.legacy_username_label.length == 0) {
 
			$('#uin_label').hide();
 
		}
 
		else {
 
			$("#uin_desc").html(data.legacy_username_label + ":");
 
			$("#uin").attr("placeholder", data.legacy_username_label);
 
		}
 

	
 
		if (data.password_label.length == 0) {
 
			$('#password_label').hide();
 
		}
 
		else {
 
			$("#password_desc").html(data.password_label + ":");
 
			$("#password").attr("placeholder", data.password_label);
 
		}
 
	});
 
}
 

	
0 comments (0 inline, 0 general)