wesnothd/fuh: Check IP address bans before everything else
There isn't much point in doing more expensive ban look ups first. (Also, yes, I am aware that as it is there's still two SELECT queries that could be coalesced into a single one -- namely, the ones for the user_email and user_id columns.)
This commit is contained in:
parent
749e684f03
commit
d48c84236c
1 changed files with 5 additions and 5 deletions
|
@ -174,6 +174,11 @@ void fuh::set_is_moderator(const std::string& name, const bool& is_moderator) {
|
|||
|
||||
fuh::BAN_TYPE fuh::user_is_banned(const std::string& name, const std::string& addr)
|
||||
{
|
||||
if(!addr.empty() && prepared_statement<bool>("SELECT 1 FROM `" + db_banlist_table_ + "` WHERE UPPER(ban_ip) = UPPER(?) AND ban_exclude = 0", addr)) {
|
||||
LOG_UH << "User '" << name << "' ip " << addr << " banned by IP address\n";
|
||||
return BAN_IP;
|
||||
}
|
||||
|
||||
if(!user_exists(name)) {
|
||||
throw error("No user with the name '" + name + "' exists.");
|
||||
}
|
||||
|
@ -188,11 +193,6 @@ fuh::BAN_TYPE fuh::user_is_banned(const std::string& name, const std::string& ad
|
|||
return BAN_USER;
|
||||
}
|
||||
|
||||
if(!addr.empty() && prepared_statement<bool>("SELECT 1 FROM `" + db_banlist_table_ + "` WHERE UPPER(ban_ip) = UPPER(?) AND ban_exclude = 0", addr)) {
|
||||
LOG_UH << "User '" << name << "' ip " << addr << " banned by IP address\n";
|
||||
return BAN_IP;
|
||||
}
|
||||
|
||||
auto email = get_detail_for_user<std::string>(name, "user_email");
|
||||
|
||||
if(!email.empty() && prepared_statement<bool>("SELECT 1 FROM `" + db_banlist_table_ + "` WHERE UPPER(ban_email) = UPPER(?) AND ban_exclude = 0", email)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue