diff --git a/dbal/cpp/src/entities/credential/helpers.hpp b/dbal/cpp/src/entities/credential/helpers.hpp new file mode 100644 index 000000000..0d0415f76 --- /dev/null +++ b/dbal/cpp/src/entities/credential/helpers.hpp @@ -0,0 +1,35 @@ +#ifndef DBAL_CREDENTIAL_HELPERS_HPP +#define DBAL_CREDENTIAL_HELPERS_HPP + +#include "../../store/in_memory_store.hpp" +#include + +namespace dbal { +namespace entities { +namespace credential { +namespace helpers { + +inline bool userExists(const InMemoryStore& store, const std::string& username) { + for (const auto& [id, user] : store.users) { + (void)id; + if (user.username == username) { + return true; + } + } + return false; +} + +inline Credential* getCredential(InMemoryStore& store, const std::string& username) { + auto it = store.credentials.find(username); + if (it == store.credentials.end()) { + return nullptr; + } + return &it->second; +} + +} // namespace helpers +} // namespace credential +} // namespace entities +} // namespace dbal + +#endif diff --git a/dbal/cpp/src/validation/validation.hpp b/dbal/cpp/src/validation/validation.hpp index ae9291aae..85f6b795f 100644 --- a/dbal/cpp/src/validation/validation.hpp +++ b/dbal/cpp/src/validation/validation.hpp @@ -13,5 +13,6 @@ #include "workflow_validation.hpp" #include "lua_script_validation.hpp" #include "package_validation.hpp" +#include "entity/credential_validation.hpp" #endif