Forward StreamError in onPasswordInvalid signal
This commit is contained in:
parent
93b2e86e9c
commit
b1e4aae55b
7 changed files with 16 additions and 9 deletions
|
@ -9,6 +9,8 @@
|
|||
#include <boost/bind.hpp>
|
||||
|
||||
#include <Swiften/Elements/ProtocolHeader.h>
|
||||
#include <Swiften/Elements/StreamError.h>
|
||||
#include <Swiften/Elements/Message.h>
|
||||
#include <Swiften/Server/UserRegistry.h>
|
||||
#include <Swiften/Network/Connection.h>
|
||||
#include <Swiften/StreamStack/XMPPLayer.h>
|
||||
|
@ -59,9 +61,14 @@ void ServerFromClientSession::handlePasswordValid() {
|
|||
}
|
||||
}
|
||||
|
||||
void ServerFromClientSession::handlePasswordInvalid() {
|
||||
void ServerFromClientSession::handlePasswordInvalid(const std::string &error) {
|
||||
if (!isInitialized()) {
|
||||
getXMPPLayer()->writeElement(boost::shared_ptr<AuthFailure>(new AuthFailure));
|
||||
if (!error.empty()) {
|
||||
boost::shared_ptr<StreamError> msg(new StreamError(StreamError::UndefinedCondition, error));
|
||||
getXMPPLayer()->writeElement(msg);
|
||||
}
|
||||
|
||||
finishSession(AuthenticationFailedError);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace Swift {
|
|||
}
|
||||
|
||||
void handlePasswordValid();
|
||||
void handlePasswordInvalid();
|
||||
void handlePasswordInvalid(const std::string &error = "");
|
||||
|
||||
private:
|
||||
void handleElement(boost::shared_ptr<Element>);
|
||||
|
|
|
@ -82,7 +82,7 @@ class UserRegistry : public Swift::UserRegistry {
|
|||
|
||||
/// Informs user that the password is invalid and disconnects him.
|
||||
/// \param user JID.
|
||||
void onPasswordInvalid(const Swift::JID &user);
|
||||
void onPasswordInvalid(const Swift::JID &user, const std::string &error = "");
|
||||
|
||||
/// Removes session later.
|
||||
/// \param user JID.
|
||||
|
|
|
@ -11,9 +11,9 @@ admin_password=test
|
|||
#cert=server.pfx #patch to PKCS#12 certificate
|
||||
#cert_password=test #password to that certificate if any
|
||||
users_per_backend=10
|
||||
#backend=/home/hanzz/code/libtransport/backends/libpurple/spectrum2_libpurple_backend
|
||||
backend=/home/hanzz/code/libtransport/backends/libpurple/spectrum2_libpurple_backend
|
||||
#backend=/usr/bin/mono /home/hanzz/code/networkplugin-csharp/msnp-sharp-backend/bin/Debug/msnp-sharp-backend.exe
|
||||
backend=/home/hanzz/code/libtransport/backends/frotz/spectrum2_frotz_backend
|
||||
#backend=/home/hanzz/code/libtransport/backends/frotz/spectrum2_frotz_backend
|
||||
#backend=../../backends/libircclient-qt/spectrum2_libircclient-qt_backend
|
||||
#protocol=prpl-msn
|
||||
protocol=any
|
||||
|
|
|
@ -369,7 +369,7 @@ void NetworkPluginServer::handleDisconnectedPayload(const std::string &data) {
|
|||
return;
|
||||
}
|
||||
|
||||
m_component->m_userRegistry->onPasswordInvalid(payload.user());
|
||||
m_component->m_userRegistry->onPasswordInvalid(payload.user(), payload.message());
|
||||
|
||||
User *user = m_userManager->getUser(payload.user());
|
||||
if (!user) {
|
||||
|
|
|
@ -299,7 +299,7 @@ void User::handleDisconnected(const std::string &error) {
|
|||
// We can't be sure finishSession sends unavailable presence everytime, so check if user gets removed
|
||||
// in finishSession(...) call and if not, remove it here.
|
||||
std::string jid = m_jid.toBare().toString();
|
||||
dynamic_cast<Swift::ServerStanzaChannel *>(m_component->getStanzaChannel())->finishSession(m_jid, boost::shared_ptr<Swift::Element>(new Swift::StreamError()));
|
||||
dynamic_cast<Swift::ServerStanzaChannel *>(m_component->getStanzaChannel())->finishSession(m_jid, boost::shared_ptr<Swift::Element>(new Swift::StreamError(Swift::StreamError::UndefinedCondition, "test")));
|
||||
if (m_userManager->getUser(jid) != NULL) {
|
||||
m_userManager->removeUser(this);
|
||||
}
|
||||
|
|
|
@ -103,11 +103,11 @@ void UserRegistry::onPasswordValid(const Swift::JID &user) {
|
|||
}
|
||||
}
|
||||
|
||||
void UserRegistry::onPasswordInvalid(const Swift::JID &user) {
|
||||
void UserRegistry::onPasswordInvalid(const Swift::JID &user, const std::string &error) {
|
||||
std::string key = user.toBare().toString();
|
||||
if (users.find(key) != users.end()) {
|
||||
LOG4CXX_INFO(logger, key << ": Password is invalid");
|
||||
users[key].session->handlePasswordInvalid();
|
||||
users[key].session->handlePasswordInvalid(error);
|
||||
users.erase(key);
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Add table
Reference in a new issue