Changeset - ddb797fdf23b
[Not reviewed]
0 2 0
HanzZ - 14 years ago 2011-08-24 00:35:34
hanzz.k@gmail.com
Do not create users entry in getPassword
2 files changed with 3 insertions and 4 deletions:
0 comments (0 inline, 0 general)
include/transport/userregistry.h
Show inline comments
 
@@ -77,32 +77,31 @@ class UserRegistry : public Swift::UserRegistry {
 
		void stopLogin(const Swift::JID& user, Swift::ServerFromClientSession *session);
 

	
 
		/// Informs user that the password is valid and finishes login process.
 
		/// \param user JID.
 
		void onPasswordValid(const Swift::JID &user);
 

	
 
		/// Informs user that the password is invalid and disconnects him.
 
		/// \param user JID.
 
		void onPasswordInvalid(const Swift::JID &user);
 

	
 
		/// Returns current password for particular user
 
		/// \param barejid JID.
 
		const std::string &getUserPassword(const std::string &barejid);
 
		const std::string getUserPassword(const std::string &barejid);
 

	
 
		/// Emitted when user wants to connect legacy network to validate the password.
 
		boost::signal<void (const Swift::JID &user)> onConnectUser;
 

	
 
		/// Emitted when user disconnected XMPP server and therefore should disconnect legacy network.
 
		boost::signal<void (const Swift::JID &user)> onDisconnectUser;
 

	
 
	private:
 
		typedef struct {
 
			std::string password;
 
			Swift::ServerFromClientSession *session;
 
		} Sess;
 

	
 
		mutable std::map<std::string, Sess> users;
 
		mutable Config *config;
 
		std::string empty;
 
};
 

	
 
}
src/userregistry.cpp
Show inline comments
 
@@ -107,19 +107,19 @@ void UserRegistry::onPasswordValid(const Swift::JID &user) {
 
void UserRegistry::onPasswordInvalid(const Swift::JID &user) {
 
	std::string key = user.toBare().toString();
 
	if (users.find(key) != users.end()) {
 
		LOG4CXX_INFO(logger, key << ": Password is invalid");
 
		users[key].session->handlePasswordInvalid();
 
		users.erase(key);
 
	}
 
	else {
 
		LOG4CXX_INFO(logger, key << ": onPasswordInvalid called for invalid user");
 
	}
 
}
 

	
 
const std::string &UserRegistry::getUserPassword(const std::string &barejid) {
 
const std::string UserRegistry::getUserPassword(const std::string &barejid) {
 
	if (users.find(barejid) != users.end())
 
		return users[barejid].password;
 
	return empty;
 
	return "";
 
}
 

	
 
}
0 comments (0 inline, 0 general)