Changeset - f081fe91875f
[Not reviewed]
0 2 0
Jan Kaluza - 13 years ago 2012-08-01 13:50:38
hanzz.k@gmail.com
Support for [registration] allowed_usernames
2 files changed with 11 insertions and 9 deletions:
0 comments (0 inline, 0 general)
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)