mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-26 14:54:55 +00:00
code: hpp,dbal,cpp (2 files)
This commit is contained in:
35
dbal/cpp/src/entities/credential/helpers.hpp
Normal file
35
dbal/cpp/src/entities/credential/helpers.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef DBAL_CREDENTIAL_HELPERS_HPP
|
||||
#define DBAL_CREDENTIAL_HELPERS_HPP
|
||||
|
||||
#include "../../store/in_memory_store.hpp"
|
||||
#include <string>
|
||||
|
||||
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
|
||||
@@ -13,5 +13,6 @@
|
||||
#include "workflow_validation.hpp"
|
||||
#include "lua_script_validation.hpp"
|
||||
#include "package_validation.hpp"
|
||||
#include "entity/credential_validation.hpp"
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user