Skip to content

Commit

Permalink
Removes unused/unimplemented nickserv functionality.
Browse files Browse the repository at this point in the history
Commands removed:
* register
* set
* details
* drop
  • Loading branch information
Pentarctagon authored and soliton- committed Aug 22, 2019
1 parent 0870d1b commit eef0c34
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 148 deletions.
16 changes: 0 additions & 16 deletions src/server/forum_user_handler.cpp
Expand Up @@ -59,14 +59,6 @@ fuh::~fuh() {
mysql_close(conn);
}

void fuh::add_user(const std::string& /*name*/, const std::string& /*mail*/, const std::string& /*password*/) {
throw error("For now please register at https://forums.wesnoth.org");
}

void fuh::remove_user(const std::string& /*name*/) {
throw error("'Dropping your nickname is currently impossible");
}

// The hashing code is basically taken from forum_auth.cpp
bool fuh::login(const std::string& name, const std::string& password, const std::string& seed) {

Expand Down Expand Up @@ -305,14 +297,6 @@ std::string fuh::user_info(const std::string& name) {
return info.str();
}

void fuh::set_user_detail(const std::string& /*user*/, const std::string& /*detail*/, const std::string& /*value*/) {
throw error("For now this is a 'read-only' user_handler");
}

std::string fuh::get_valid_details() {
return "For now this is a 'read-only' user_handler";
}

std::string fuh::get_hash(const std::string& user) {
try {
return get_detail_for_user<std::string>(user, "user_password");
Expand Down
10 changes: 0 additions & 10 deletions src/server/forum_user_handler.hpp
Expand Up @@ -43,12 +43,6 @@ class fuh : public user_handler {
fuh(const config& c);
~fuh();

// Throws user_handler::error
void add_user(const std::string& name, const std::string& mail, const std::string& password);

// Throws user_handler::error
void remove_user(const std::string& name);

void clean_up() {}

bool login(const std::string& name, const std::string& password, const std::string& seed);
Expand All @@ -75,10 +69,6 @@ class fuh : public user_handler {
// Throws user_handler::error
std::string user_info(const std::string& name);

// Throws user_handler::error
void set_user_detail(const std::string& user, const std::string& detail, const std::string& value);
std::string get_valid_details();

bool use_phpbb_encryption() const { return true; }

std::string get_uuid();
Expand Down
96 changes: 0 additions & 96 deletions src/server/server.cpp
Expand Up @@ -1197,67 +1197,6 @@ void server::handle_nickserv(socket_ptr socket, simple_wml::node& nickserv)
return;
}

if(nickserv.child("register")) {
try {
(user_handler_->add_user(player_connections_.find(socket)->name(),
(*nickserv.child("register"))["mail"].to_string(),
(*nickserv.child("register"))["password"].to_string()));

std::stringstream msg;
msg << "Your username has been registered." <<
// Warn that providing an email address might be a good idea
((*nickserv.child("register"))["mail"].empty()
? " It is recommended that you provide an email address for password recovery."
: "");

send_server_message(socket, msg.str());

// Mark the player as registered and send the other clients
// an update to display this change
player_connections_.find(socket)->info().mark_registered();

simple_wml::document diff;
make_change_diff(games_and_users_list_.root(), nullptr, "user",
player_connections_.find(socket)->info().config_address(), diff);
send_to_lobby(diff);

} catch(const user_handler::error& e) {
send_server_message(socket,
"There was an error registering your username. The error message was: " + e.message);
}

return;
}

// A user requested to update his password or mail
if(nickserv.child("set")) {
if(!(user_handler_->user_exists(player_connections_.find(socket)->name()))) {
send_server_message(socket, "You are not registered. Please register first.");
return;
}

const simple_wml::node& set = *(nickserv.child("set"));

try {
user_handler_->set_user_detail(
player_connections_.find(socket)->name(), set["detail"].to_string(), set["value"].to_string());

send_server_message(socket, "Your details have been updated.");

} catch(const user_handler::error& e) {
send_server_message(socket,
"There was an error updating your details. The error message was: " + e.message);
}

return;
}

// A user requested information about another user
if(nickserv.child("details")) {
send_server_message(socket, "Valid details for this server are: " + user_handler_->get_valid_details());
return;
}

// A user requested a list of which details can be set
if(nickserv.child("info")) {
try {
Expand All @@ -1273,41 +1212,6 @@ void server::handle_nickserv(socket_ptr socket, simple_wml::node& nickserv)

return;
}

// A user requested to delete his nick
if(nickserv.child("drop")) {
if(!(user_handler_->user_exists(player_connections_.find(socket)->name()))) {
send_server_message(socket, "You are not registered.");
return;
}

// With the current policy of dissallowing to log in with a
// registered username without the password we should never get
// to call this
if(!(player_connections_.find(socket)->info().registered())) {
send_server_message(socket, "You are not logged in.");
return;
}

try {
user_handler_->remove_user(player_connections_.find(socket)->name());
send_server_message(socket, "Your username has been dropped.");

// Mark the player as not registered and send the other clients
// an update to display this change.
player_connections_.find(socket)->info().mark_registered(false);

simple_wml::document diff;
make_change_diff(games_and_users_list_.root(), nullptr, "user",
player_connections_.find(socket)->info().config_address(), diff);

send_to_lobby(diff);
} catch(const user_handler::error& e) {
send_server_message(socket,
"There was an error dropping your username. The error message was: " + e.message);
}
return;
}
}

void server::handle_message(socket_ptr socket, simple_wml::node& message)
Expand Down
26 changes: 0 additions & 26 deletions src/server/user_handler.hpp
Expand Up @@ -43,22 +43,6 @@ class user_handler {
{
}

/**
* Adds a user.
*
* Throws an error containing the error message if adding fails
* (e.g. because a user with the same name already exists).
*/
virtual void add_user(const std::string& name, const std::string& mail, const std::string& password) =0;

/**
* Removes a user.
*
* Throws an error containing the error message if removing fails
* (e.g. no user with the given name exists).
*/
virtual void remove_user(const std::string& name) =0;

/**
* Called by the server once a day.
*
Expand Down Expand Up @@ -87,16 +71,6 @@ class user_handler {
*/
virtual std::string user_info(const std::string& name) =0;

/**
* Set data for a given user name.
*
* Should throw an error on invalid data.
*/
virtual void set_user_detail(const std::string& user, const std::string& detail, const std::string& value) =0;

/** List of details that can be set for this user_handler. */
virtual std::string get_valid_details() =0;

/** Returns true if a user with the given name exists. */
virtual bool user_exists(const std::string& name) =0;

Expand Down

0 comments on commit eef0c34

Please sign in to comment.