bmcweb: Add JSON response to /logout
When logging out of the API, there was no JSON text response.
This implements the requested feature.
Tested: Verified appropriate response is generated when /logout
is called
E.g.
curl -c cjar -b cjar -k -X POST \
-H "Content-Type: application/json" \
-H "X-Auth-Token: g3Heq5rYsz1j0iv4MbUp" \
-d '{"data": [ ] }' \
https://${bmc}/logout
{
"data": "User 'root' logged out",
"message": "200 OK",
"status": "ok"
}
Change-Id: I905f5a0855abaa76ae57cf32b8bae758722f6b9f
Signed-off-by: Anthony Wilson <wilsonan@us.ibm.com>
diff --git a/include/token_authorization_middleware.hpp b/include/token_authorization_middleware.hpp
index c5c6523..697e400 100644
--- a/include/token_authorization_middleware.hpp
+++ b/include/token_authorization_middleware.hpp
@@ -438,6 +438,11 @@
.session;
if (session != nullptr)
{
+ res.jsonValue = {
+ {"data", "User '" + session->username + "' logged out"},
+ {"message", "200 OK"},
+ {"status", "ok"}};
+
persistent_data::SessionStore::getInstance().removeSession(
session);
}