Remove utils::hasKey(), as we now have .contains()
This commit is contained in:
parent
d035579da7
commit
873401694e
@ -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);
|
||||||
|
6
utils.h
6
utils.h
@ -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);
|
||||||
|
@ -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];
|
||||||
|
Loading…
Reference in New Issue
Block a user