Changeset - 1c1adbd7d5d8
[Not reviewed]
Merge
0 5 4
HanzZ - 13 years ago 2012-08-01 20:01:04
hanzz.k@gmail.com
Merge branch 'master' of github.com:hanzz/libtransport
3 files changed with 17 insertions and 10 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/main.cpp
Show inline comments
 
@@ -344,8 +344,13 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
 
			}
 

	
 
			if (purple_accounts_find(name.c_str(), protocol.c_str()) != NULL) {
 
				LOG4CXX_INFO(logger, "Using previously created account with name '" << name.c_str() << "' and protocol '" << protocol << "'");
 
				account = purple_accounts_find(name.c_str(), protocol.c_str());
 
				if (m_accounts.find(account) != m_accounts.end() && m_accounts[account] != user) {
 
					LOG4CXX_INFO(logger, "Account '" << name << "' is already used by '" << m_accounts[account] << "'");
 
					np->handleDisconnected(user, 0, "Account '" + name + "' is already used by '" + m_accounts[account] + "'");
 
					return;
 
				}
 
				LOG4CXX_INFO(logger, "Using previously created account with name '" << name.c_str() << "' and protocol '" << protocol << "'");
 
			}
 
			else {
 
				LOG4CXX_INFO(logger, "Creating account with name '" << name.c_str() << "' and protocol '" << protocol << "'");
src/config.cpp
Show inline comments
 
@@ -101,6 +101,7 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description
 
		("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_mask", value<std::string>()->default_value(""), "Username mask")
 
		("registration.allowed_usernanames", value<std::string>()->default_value(""), "Allowed usernames")
 
		("registration.auto_register", value<bool>()->default_value(false), "Register new user automatically when the presence arrives.")
 
		("registration.encoding", value<std::string>()->default_value("utf8"), "Default encoding in registration form")
 
		("registration.require_local_account", value<bool>()->default_value(false), "True if users have to have a local account to register to this transport from remote servers.")
src/userregistration.cpp
Show inline comments
 
@@ -29,6 +29,7 @@
 
#include <boost/shared_ptr.hpp>
 
#include <boost/thread.hpp>
 
#include <boost/date_time/posix_time/posix_time.hpp>
 
#include <boost/regex.hpp> 
 

	
 
using namespace Swift;
 

	
 
@@ -441,15 +442,15 @@ bool UserRegistration::handleSetRequest(const Swift::JID& from, const Swift::JID
 
// 		return true;
 
// 	}
 

	
 
//TODO: Part of spectrum1 registration stuff, this should be potentially rewritten for S2 too
 
// #if GLIB_CHECK_VERSION(2,14,0)
 
// 	if (!CONFIG_STRING(m_config, "registration.reg_allowed_usernames").empty() &&
 
// 		!g_regex_match_simple(CONFIG_STRING(m_config, "registration.reg_allowed_usernames"), newUsername.c_str(),(GRegexCompileFlags) (G_REGEX_CASELESS | G_REGEX_EXTENDED), (GRegexMatchFlags) 0)) {
 
// 		Log("UserRegistration", "This is not valid username: "<< newUsername);
 
// 		sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify);
 
// 		return true;
 
// 	}
 
// #endif
 
	if (!CONFIG_STRING(m_config, "registration.allowed_usernames").empty()) {
 
		boost::regex expression(CONFIG_STRING(m_config, "registration.allowed_usernames"));
 
		if (!regex_match(newUsername, expression)) {
 
			LOG4CXX_INFO(logger, "This is not valid username: " << newUsername);
 
			sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify);
 
			return true;
 
		}
 
	}
 

	
 
	if (!registered) {
 
		res.jid = barejid;
 
		res.uin = newUsername;
0 comments (0 inline, 0 general)