Expose current Role in Session object

As discussed at https://gerrit.openbmc.org/c/openbmc/webui-vue/+/70758
having that information available to front end is desired for UX
purposes (hiding pages and actions that are not permitted to the current
user anyway).

This field was added in #Session.v1_7_0.Session released on 2023.2.

Tested: current role correctly reported (e.g. "Administrator") as the
only array element, Redfish-Service-Validator passes.

Fixes: #275
Change-Id: Ic9d8f02ca5859cb4b9996fd85b0896ce76ea22aa
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
diff --git a/Redfish.md b/Redfish.md
index 2ec6381..734802e 100644
--- a/Redfish.md
+++ b/Redfish.md
@@ -728,6 +728,7 @@
 
 - ClientOriginIPAddress
 - Description
+- Roles
 - UserName
 
 ### /redfish/v1/Systems/
diff --git a/redfish-core/lib/redfish_sessions.hpp b/redfish-core/lib/redfish_sessions.hpp
index 3971791..b38f924 100644
--- a/redfish-core/lib/redfish_sessions.hpp
+++ b/redfish-core/lib/redfish_sessions.hpp
@@ -15,6 +15,7 @@
 */
 #pragma once
 
+#include "account_service.hpp"
 #include "app.hpp"
 #include "error_messages.hpp"
 #include "http/utility.hpp"
@@ -33,9 +34,12 @@
 {
     res.jsonValue["Id"] = session.uniqueId;
     res.jsonValue["UserName"] = session.username;
+    nlohmann::json::array_t roles;
+    roles.emplace_back(redfish::getRoleIdFromPrivilege(session.userRole));
+    res.jsonValue["Roles"] = std::move(roles);
     res.jsonValue["@odata.id"] = boost::urls::format(
         "/redfish/v1/SessionService/Sessions/{}", session.uniqueId);
-    res.jsonValue["@odata.type"] = "#Session.v1_5_0.Session";
+    res.jsonValue["@odata.type"] = "#Session.v1_7_0.Session";
     res.jsonValue["Name"] = "User Session";
     res.jsonValue["Description"] = "Manager User Session";
     res.jsonValue["ClientOriginIPAddress"] = session.clientIp;