From 1cf9894f7d3f59fbe3b656c1ce9d9421946753ed Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Tue, 28 Dec 2021 11:14:58 -0800 Subject: [PATCH] Framework update --- build | 2 +- src/storage/orm_users.cpp | 12 +++++++++--- src/storage/orm_users.h | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/build b/build index 34bba94..2bab422 100644 --- a/build +++ b/build @@ -1 +1 @@ -156 \ No newline at end of file +157 \ No newline at end of file diff --git a/src/storage/orm_users.cpp b/src/storage/orm_users.cpp index f060e92..99d32d0 100644 --- a/src/storage/orm_users.cpp +++ b/src/storage/orm_users.cpp @@ -4,6 +4,8 @@ #include "orm_users.h" #include "AuthService.h" +#include "RESTObjects/RESTAPI_CertObjects.h" +#include "StorageService.h" /* std::string, // Id = 0; @@ -90,7 +92,6 @@ namespace OpenWifi { DB(T, Name.c_str(), BaseUserDB_Fields, MakeIndices(ShortName), P, L, ShortName.c_str()) { } - bool BaseUserDB::CreateUser(const std::string & Admin, SecurityObjects::UserInfo & NewUser, bool PasswordHashedAlready ) { try { Poco::toLowerInPlace(NewUser.email); @@ -145,9 +146,9 @@ namespace OpenWifi { return false; } - bool BaseUserDB::GetUsers( uint64_t Offset, uint64_t HowMany, SecurityObjects::UserInfoVec & Users) { + bool BaseUserDB::GetUsers( uint64_t Offset, uint64_t HowMany, SecurityObjects::UserInfoVec & Users, std::string WhereClause) { try { - return GetRecords(Offset, HowMany, Users); + return GetRecords(Offset, HowMany, Users, WhereClause); } catch (const Poco::Exception &E) { Logger().log(E); } @@ -199,6 +200,11 @@ namespace OpenWifi { return false; } + bool BaseUserDB::DeleteUsers(const std::string & Admin, std::string & owner) { + std::string WhereClause{ " owner='" + owner +"' "}; + return DeleteRecords(WhereClause); + } + bool BaseUserDB::SetLastLogin(const std::string &Id) { try { Poco::Data::Session Sess = Pool_.get(); diff --git a/src/storage/orm_users.h b/src/storage/orm_users.h index e8bd0d8..060ae80 100644 --- a/src/storage/orm_users.h +++ b/src/storage/orm_users.h @@ -86,9 +86,10 @@ namespace OpenWifi { bool CreateUser(const std::string & Admin, SecurityObjects::UserInfo & NewUser, bool PasswordHashedAlready = false ); bool GetUserByEmail(const std::string & email, SecurityObjects::UserInfo & User); bool GetUserById(const std::string &Id, SecurityObjects::UserInfo &User); - bool GetUsers( uint64_t Offset, uint64_t HowMany, SecurityObjects::UserInfoVec & Users); + bool GetUsers( uint64_t Offset, uint64_t HowMany, SecurityObjects::UserInfoVec & Users, std::string WhereClause=""); bool UpdateUserInfo(const std::string & Admin, USER_ID_TYPE & Id, SecurityObjects::UserInfo &UInfo); bool DeleteUser(const std::string & Admin, USER_ID_TYPE & Id); + bool DeleteUsers(const std::string & Admin, std::string & owner); bool SetLastLogin(const std::string &Id); bool SetAvatar(const std::string &Id, const std::string &Value);