From 71b28a1ff23af56be854f53b2fbbb917c81cc79d Mon Sep 17 00:00:00 2001 From: JohnDoe6345789 Date: Fri, 26 Dec 2025 06:02:59 +0000 Subject: [PATCH] code: hpp,dbal,cpp (2 files) --- dbal/cpp/src/entities/credential/helpers.hpp | 35 ++++++++++++++++++++ dbal/cpp/src/validation/validation.hpp | 1 + 2 files changed, 36 insertions(+) create mode 100644 dbal/cpp/src/entities/credential/helpers.hpp 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