Skip to content

Commit

Permalink
deauth all members upon network delete
Browse files Browse the repository at this point in the history
  • Loading branch information
glimberg committed Jun 17, 2024
1 parent 255e51b commit 3141107
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions controller/DB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,24 @@ void DB::_networkChanged(nlohmann::json &old,nlohmann::json &networkConfig,bool
const std::string ids = old["id"];
const uint64_t networkId = Utils::hexStrToU64(ids.c_str());
if (networkId) {
try {
// deauth all members on the network
nlohmann::json network;
std::vector<nlohmann::json> members;
this->get(networkId, network, members);
for(auto i=members.begin();i!=members.end();++i) {
const std::string nodeID = (*i)["id"];
const uint64_t memberId = Utils::hexStrToU64(nodeID.c_str());
std::unique_lock<std::shared_mutex> ll(_changeListeners_l);
for(auto j=_changeListeners.begin();j!=_changeListeners.end();++j) {
(*j)->onNetworkMemberDeauthorize(this,networkId,memberId);
}
}
} catch (std::exception &e) {
std::cerr << "Error deauthorizing members on network delete: " << e.what() << std::endl;
}

// delete the network
std::unique_lock<std::shared_mutex> l(_networks_l);
_networks.erase(networkId);
}
Expand Down

0 comments on commit 3141107

Please sign in to comment.