From 581cc766254b3b2bc3bccdcbd49c7617c3baf717 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Tue, 19 Oct 2021 08:05:07 -0700 Subject: [PATCH] Added the ability to get user by email --- build | 2 +- src/MicroService.h | 2 ++ src/RESTAPI_user_handler.cpp | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/build b/build index 7c6ba0f..2ebc651 100644 --- a/build +++ b/build @@ -1 +1 @@ -55 \ No newline at end of file +56 \ No newline at end of file diff --git a/src/MicroService.h b/src/MicroService.h index 1dbf62a..f99afda 100644 --- a/src/MicroService.h +++ b/src/MicroService.h @@ -39,6 +39,8 @@ namespace OpenWifi { static const std::string uSERVICE_TOPOLOGY{ "owtopo"}; static const std::string uSERVICE_PROVISIONING{ "owprov"}; static const std::string uSERVICE_OWLS{ "owls"}; + static const std::string uSERVICE_SUBCRIBER{ "owsub"}; + static const std::string uSERVICE_INSTALLER{ "owinst"}; class MyErrorHandler : public Poco::ErrorHandler { public: diff --git a/src/RESTAPI_user_handler.cpp b/src/RESTAPI_user_handler.cpp index 80dbdf4..5059a39 100644 --- a/src/RESTAPI_user_handler.cpp +++ b/src/RESTAPI_user_handler.cpp @@ -17,8 +17,12 @@ namespace OpenWifi { return BadRequest(RESTAPI::Errors::MissingUserID); } + Poco::toLowerInPlace(Id); + std::string Arg; SecurityObjects::UserInfo UInfo; - if(!Storage()->GetUserById(Id,UInfo)) { + if(HasParameter("byEmail",Arg) && Arg=="true" && !Storage()->GetUserByEmail(Id,UInfo)) { + return NotFound(); + } else if(!Storage()->GetUserById(Id,UInfo)) { return NotFound(); } Poco::JSON::Object UserInfoObject;