| #ifndef THIRD_PARTY_GBMCWEB_INCLUDE_USER_MONITOR_H_ |
| #define THIRD_PARTY_GBMCWEB_INCLUDE_USER_MONITOR_H_ |
| |
| #include <string> |
| |
| #include "sessions.hpp" |
| #include "managed_store.hpp" |
| #include "sdbusplus/bus/match.hpp" |
| #include "sdbusplus/message.hpp" |
| #include "sdbusplus/message/native_types.hpp" |
| |
| #ifdef UNIT_TEST_BUILD |
| #include "test/g3/mock_managed_store.hpp" // NOLINT |
| #endif |
| |
| namespace bmcweb { |
| |
| inline void onUserRemoved(sdbusplus::message_t& msg) { |
| sdbusplus::message::object_path p; |
| msg.read(p); |
| std::string username = p.filename(); |
| persistent_data::SessionStore::getInstance().removeSessionsByUsername( |
| username); |
| } |
| |
| inline void registerUserRemovedSignal() { |
| std::string userRemovedMatchStr = |
| sdbusplus::bus::match::rules::interfacesRemoved( |
| "/xyz/openbmc_project/user"); |
| |
| static sdbusplus::bus::match_t userRemovedMatch( |
| *(managedStore::GetManagedObjectStore() |
| ->GetDeprecatedThreadUnsafeSystemBus()), |
| userRemovedMatchStr, onUserRemoved); |
| } |
| } // namespace bmcweb |
| |
| #endif // THIRD_PARTY_GBMCWEB_INCLUDE_USER_MONITOR_H_ |