From 75aaf4f45ba1cf2d6f12aadc5192e6f1c5c18b5d Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Tue, 19 Oct 2021 08:23:34 -0700 Subject: [PATCH] Added the ability to get user by email --- src/RESTAPI_user_handler.cpp | 8 +++++--- test_scripts/curl/cli | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/RESTAPI_user_handler.cpp b/src/RESTAPI_user_handler.cpp index 6a73ce7..88354e6 100644 --- a/src/RESTAPI_user_handler.cpp +++ b/src/RESTAPI_user_handler.cpp @@ -20,9 +20,11 @@ namespace OpenWifi { Poco::toLowerInPlace(Id); std::string Arg; SecurityObjects::UserInfo UInfo; - if(HasParameter("byEmail",Arg) && Arg=="true" && !Storage()->GetUserByEmail(Id,UInfo)) { - std::cout << "Could not find e-mail: " << Id << std::endl; - return NotFound(); + if(HasParameter("byEmail",Arg) && Arg=="true") { + if(!Storage()->GetUserByEmail(Id,UInfo)) { + std::cout << "Could not find e-mail: " << Id << std::endl; + return NotFound(); + } } else if(!Storage()->GetUserById(Id,UInfo)) { std::cout << "Could not find ID: " << Id << std::endl; return NotFound(); diff --git a/test_scripts/curl/cli b/test_scripts/curl/cli index 8592998..133da92 100755 --- a/test_scripts/curl/cli +++ b/test_scripts/curl/cli @@ -200,12 +200,13 @@ getuser() { } getuserbyemail() { - curl ${FLAGS} -X GET "https://${OWSEC}/api/v1/user/$1?byEmail=true" \ + curl ${FLAGS} -X GET "https://${OWSEC}/api/v1/user/${1}?byEmail=true" \ -H "accept: application/json" \ -H "Authorization: Bearer ${token}" \ -d "$payload" > ${result_file} jq < ${result_file} } + listusers() { curl ${FLAGS} -X GET "https://${OWSEC}/api/v1/users" \ -H "accept: application/json" \