registration.auto_register option
This commit is contained in:
parent
6ba5bdf44a
commit
ece09d41b7
3 changed files with 35 additions and 4 deletions
|
@ -50,10 +50,12 @@ void SingleIRCNetworkPlugin::handleLoginRequest(const std::string &user, const s
|
|||
session->setHost(QString::fromStdString(m_server));
|
||||
session->setPort(6667);
|
||||
|
||||
std::string identify = m_identify;
|
||||
boost::replace_all(identify, "$password", password);
|
||||
boost::replace_all(identify, "$name", legacyName);
|
||||
session->setIdentify(identify);
|
||||
if (!password.empty()) {
|
||||
std::string identify = m_identify;
|
||||
boost::replace_all(identify, "$password", password);
|
||||
boost::replace_all(identify, "$name", legacyName);
|
||||
session->setIdentify(identify);
|
||||
}
|
||||
|
||||
session->open();
|
||||
|
||||
|
|
|
@ -93,6 +93,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.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.")
|
||||
("registration.local_username_label", value<std::string>()->default_value("Local username:"), "Label for local usernme field")
|
||||
|
|
|
@ -214,6 +214,34 @@ void UserManager::handlePresence(Swift::Presence::ref presence) {
|
|||
res.password = m_userRegistry->getUserPassword(userkey);
|
||||
}
|
||||
|
||||
// We allow auto_register feature in gateway-mode. This allows IRC user to register
|
||||
// the transport just by joining the room.
|
||||
if (!m_component->inServerMode()) {
|
||||
if (!registered && CONFIG_BOOL(m_component->getConfig(), "registration.auto_register")) {
|
||||
res.password = "";
|
||||
res.jid = userkey;
|
||||
|
||||
bool isMUC = presence->getPayload<Swift::MUCPayload>() != NULL || *presence->getTo().getNode().c_str() == '#';
|
||||
if (isMUC) {
|
||||
res.uin = presence->getTo().getResource();
|
||||
}
|
||||
else {
|
||||
res.uin = presence->getFrom().toString();
|
||||
}
|
||||
LOG4CXX_INFO(logger, "Auto-registering user " << userkey << " with uin=" << res.uin);
|
||||
|
||||
if (m_storageBackend) {
|
||||
// store user and getUser again to get user ID.
|
||||
m_storageBackend->setUser(res);
|
||||
registered = m_storageBackend->getUser(userkey, res);
|
||||
}
|
||||
else {
|
||||
registered = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Unregistered users are not able to login
|
||||
if (!registered) {
|
||||
LOG4CXX_WARN(logger, "Unregistered user " << userkey << " tried to login");
|
||||
|
|
Loading…
Add table
Reference in a new issue