blob: 70c4a1e9daf4045e8cac9925d6a6f13f86295d86 [file] [log] [blame]
Ed Tanous40e9b922024-09-10 13:50:16 -07001// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright OpenBMC Authors
Xie Ning9fa06f12022-06-29 18:27:47 +08003#pragma once
4#include "dbus_singleton.hpp"
Ed Tanousd7857202025-01-28 15:32:26 -08005#include "sessions.hpp"
Xie Ning9fa06f12022-06-29 18:27:47 +08006
7#include <sdbusplus/bus/match.hpp>
Ed Tanousd7857202025-01-28 15:32:26 -08008#include <sdbusplus/message.hpp>
9#include <sdbusplus/message/native_types.hpp>
10
11#include <string>
Xie Ning9fa06f12022-06-29 18:27:47 +080012
13namespace bmcweb
14{
15
Patrick Williamsca165b92023-02-28 02:40:35 -060016inline void onUserRemoved(sdbusplus::message_t& msg)
Xie Ning9fa06f12022-06-29 18:27:47 +080017{
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
25inline 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