From d162327d3aceb712d65ab83c8029e67a088f0ee3 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Mon, 10 Jul 2023 13:16:11 -0700 Subject: [PATCH] https://telecominfraproject.atlassian.net/browse/WIFI-12738 Signed-off-by: stephb9959 --- CMakeLists.txt | 2 +- build | 2 +- src/framework/RESTAPI_utils.h | 7 +++++++ src/framework/utils.cpp | 4 ++++ src/framework/utils.h | 1 + 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9780b8..e5dab1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.13) -project(owanalytics VERSION 2.10.0) +project(owanalytics VERSION 2.11.0) set(CMAKE_CXX_STANDARD 17) set(CMAKE_GENERATOR "Unix Makefiles") diff --git a/build b/build index 25bf17f..56a6051 100644 --- a/build +++ b/build @@ -1 +1 @@ -18 \ No newline at end of file +1 \ No newline at end of file diff --git a/src/framework/RESTAPI_utils.h b/src/framework/RESTAPI_utils.h index a3eca9d..72c0afc 100644 --- a/src/framework/RESTAPI_utils.h +++ b/src/framework/RESTAPI_utils.h @@ -14,8 +14,15 @@ #include "framework/OpenWifiTypes.h" #include "framework/utils.h" +#include + namespace OpenWifi::RESTAPI_utils { + inline bool IsRootOrAdmin(const SecurityObjects::UserInfo &UI) { + return UI.userRole==SecurityObjects::ROOT || + UI.userRole==SecurityObjects::ADMIN; + } + inline void EmbedDocument(const std::string &ObjName, Poco::JSON::Object &Obj, const std::string &ObjStr) { std::string D = ObjStr.empty() ? "{}" : ObjStr; diff --git a/src/framework/utils.cpp b/src/framework/utils.cpp index 55e0b55..c2f4358 100644 --- a/src/framework/utils.cpp +++ b/src/framework/utils.cpp @@ -27,6 +27,10 @@ namespace OpenWifi::Utils { std::all_of(Serial.begin(), Serial.end(), [](auto i) { return std::isxdigit(i); })); } + [[nodiscard]] bool ValidSerialNumbers(const std::vector &numbers) { + return std::all_of(numbers.begin(),numbers.end(),[](auto &number) {return ValidSerialNumber(number);}); + } + [[nodiscard]] bool ValidUUID(const std::string &UUID) { if (UUID.size() > 36) return false; diff --git a/src/framework/utils.h b/src/framework/utils.h index f1cdef3..0228bff 100644 --- a/src/framework/utils.h +++ b/src/framework/utils.h @@ -68,6 +68,7 @@ namespace OpenWifi::Utils { }; [[nodiscard]] bool ValidSerialNumber(const std::string &Serial); + [[nodiscard]] bool ValidSerialNumbers(const std::vector &Serial); [[nodiscard]] bool ValidUUID(const std::string &UUID); [[nodiscard]] bool ValidHostname(const std::string &hostname);