Ed Tanous | 40e9b92 | 2024-09-10 13:50:16 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // SPDX-FileCopyrightText: Copyright OpenBMC Authors |
Xie Ning | 9fa06f1 | 2022-06-29 18:27:47 +0800 | [diff] [blame] | 3 | #pragma once |
| 4 | #include "dbus_singleton.hpp" |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 5 | #include "sessions.hpp" |
Xie Ning | 9fa06f1 | 2022-06-29 18:27:47 +0800 | [diff] [blame] | 6 | |
| 7 | #include <sdbusplus/bus/match.hpp> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 8 | #include <sdbusplus/message.hpp> |
| 9 | #include <sdbusplus/message/native_types.hpp> |
| 10 | |
| 11 | #include <string> |
Xie Ning | 9fa06f1 | 2022-06-29 18:27:47 +0800 | [diff] [blame] | 12 | |
| 13 | namespace bmcweb |
| 14 | { |
| 15 | |
Patrick Williams | ca165b9 | 2023-02-28 02:40:35 -0600 | [diff] [blame] | 16 | inline void onUserRemoved(sdbusplus::message_t& msg) |
Xie Ning | 9fa06f1 | 2022-06-29 18:27:47 +0800 | [diff] [blame] | 17 | { |
| 18 | sdbusplus::message::object_path p; |
| 19 | msg.read(p); |
| 20 | std::string username = p.filename(); |
| 21 | persistent_data::SessionStore::getInstance().removeSessionsByUsername( |
| 22 | username); |
| 23 | } |
| 24 | |
| 25 | inline void registerUserRemovedSignal() |
| 26 | { |
| 27 | std::string userRemovedMatchStr = |
| 28 | sdbusplus::bus::match::rules::interfacesRemoved( |
| 29 | "/xyz/openbmc_project/user"); |
| 30 | |
| 31 | static sdbusplus::bus::match_t userRemovedMatch( |
| 32 | *crow::connections::systemBus, userRemovedMatchStr, onUserRemoved); |
| 33 | } |
| 34 | } // namespace bmcweb |