Added the ability to get user by email

This commit is contained in:
stephb9959
2021-10-19 08:23:34 -07:00
parent 7161175f03
commit 75aaf4f45b
2 changed files with 7 additions and 4 deletions

View File

@@ -20,9 +20,11 @@ namespace OpenWifi {
Poco::toLowerInPlace(Id); Poco::toLowerInPlace(Id);
std::string Arg; std::string Arg;
SecurityObjects::UserInfo UInfo; SecurityObjects::UserInfo UInfo;
if(HasParameter("byEmail",Arg) && Arg=="true" && !Storage()->GetUserByEmail(Id,UInfo)) { if(HasParameter("byEmail",Arg) && Arg=="true") {
if(!Storage()->GetUserByEmail(Id,UInfo)) {
std::cout << "Could not find e-mail: " << Id << std::endl; std::cout << "Could not find e-mail: " << Id << std::endl;
return NotFound(); return NotFound();
}
} else if(!Storage()->GetUserById(Id,UInfo)) { } else if(!Storage()->GetUserById(Id,UInfo)) {
std::cout << "Could not find ID: " << Id << std::endl; std::cout << "Could not find ID: " << Id << std::endl;
return NotFound(); return NotFound();

View File

@@ -200,12 +200,13 @@ getuser() {
} }
getuserbyemail() { 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 "accept: application/json" \
-H "Authorization: Bearer ${token}" \ -H "Authorization: Bearer ${token}" \
-d "$payload" > ${result_file} -d "$payload" > ${result_file}
jq < ${result_file} jq < ${result_file}
} }
listusers() { listusers() {
curl ${FLAGS} -X GET "https://${OWSEC}/api/v1/users" \ curl ${FLAGS} -X GET "https://${OWSEC}/api/v1/users" \
-H "accept: application/json" \ -H "accept: application/json" \