Remove utils::hasKey(), as we now have .contains()

This commit is contained in:
Albert S. 2021-10-19 12:48:45 +02:00
parent d035579da7
commit 873401694e
3 changed files with 3 additions and 9 deletions

View File

@ -21,7 +21,7 @@ Authenticator::Authenticator(UserDao &userDao)
// TODO: make failure counter configurable // TODO: make failure counter configurable
bool Authenticator::isBanned(std::string ip) bool Authenticator::isBanned(std::string ip)
{ {
if(utils::hasKey(loginFails, ip)) if(loginFails.contains(ip))
{ {
LoginFail &fl = loginFails[ip]; LoginFail &fl = loginFails[ip];
std::lock_guard<std::mutex> lock(fl.mutex); std::lock_guard<std::mutex> lock(fl.mutex);

View File

@ -20,12 +20,6 @@ std::string strreplace(std::string str, const std::string &search, const std::st
std::string html_xss(std::string_view str); std::string html_xss(std::string_view str);
std::string getenv(const std::string &key); std::string getenv(const std::string &key);
template <class T, class U> bool hasKey(const std::map<T, U> &map, const T &key)
{
auto k = map.find(key);
return k != map.end();
}
template <class T, class U> U getKeyOrEmpty(const std::map<T, U> &map, const T &key) template <class T, class U> U getKeyOrEmpty(const std::map<T, U> &map, const T &key)
{ {
auto k = map.find(key); auto k = map.find(key);

View File

@ -60,12 +60,12 @@ std::string Varreplacer::makeReplacement(std::string_view varkeyvalue)
std::string_view value; std::string_view value;
std::tie(key, value) = extractKeyAndValue(varkeyvalue); std::tie(key, value) = extractKeyAndValue(varkeyvalue);
if(utils::hasKey(keyValues, key)) if(keyValues.contains(key))
{ {
std::string replacementContent = keyValues[key]; std::string replacementContent = keyValues[key];
return replacementContent; return replacementContent;
} }
else if(utils::hasKey(resolverFunctionsMap, key)) else if(resolverFunctionsMap.contains(key))
{ {
auto resolver = this->resolverFunctionsMap[key]; auto resolver = this->resolverFunctionsMap[key];