[Fix] User deletion & migration
This commit is contained in:
parent
da5a5a5dff
commit
722eb9b025
8 changed files with 150 additions and 119 deletions
|
|
@ -77,6 +77,12 @@ impl ClientConnection {
|
|||
*self.rho_connection.write().await = Some(rho_connection);
|
||||
}
|
||||
|
||||
/// A membership snapshot can remove an account from an Iota while keeping
|
||||
/// its authenticated Omega connection alive.
|
||||
pub async fn clear_rho_connection(&self) {
|
||||
*self.rho_connection.write().await = None;
|
||||
}
|
||||
|
||||
/// Send a CommunicationValue to the client
|
||||
pub async fn send_message(self: Arc<Self>, cv: &CommunicationValue) {
|
||||
if !*self.is_open.read().await {
|
||||
|
|
|
|||
|
|
@ -442,6 +442,12 @@ impl IotaConnection {
|
|||
|| cv.is_type(CommunicationType::GetUserData)
|
||||
|| cv.is_type(CommunicationType::GetIotaData)
|
||||
|| cv.is_type(CommunicationType::DeleteIota)
|
||||
|| cv.is_type(CommunicationType::AttachUserBegin)
|
||||
|| cv.is_type(CommunicationType::AttachUserComplete)
|
||||
|| cv.is_type(CommunicationType::ReleaseUserFromIota)
|
||||
|| cv.is_type(CommunicationType::DeleteUserCredentialBegin)
|
||||
|| cv.is_type(CommunicationType::DeleteUserCredentialComplete)
|
||||
|| cv.is_type(CommunicationType::EraseHostedUserDataAck)
|
||||
{
|
||||
let sender = self.get_iota_id().await;
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,14 @@ impl RhoConnection {
|
|||
.collect()
|
||||
}
|
||||
|
||||
pub async fn detach_user_clients(&self, user_id: i64) {
|
||||
let clients = self.get_client_connections_for_user(user_id).await;
|
||||
for client in clients {
|
||||
client.clear_rho_connection().await;
|
||||
}
|
||||
self.client_connections.retain(|(id, _), _| *id != user_id as u64);
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub async fn get_app_connections(
|
||||
&self,
|
||||
|
|
|
|||
|
|
@ -66,7 +66,11 @@ impl RhoManager {
|
|||
)
|
||||
.await;
|
||||
|
||||
let replacement = user_ids.iter().copied().collect::<std::collections::HashSet<_>>();
|
||||
for user_id in previous_users {
|
||||
if !replacement.contains(&user_id) {
|
||||
rho.detach_user_clients(user_id).await;
|
||||
}
|
||||
if self
|
||||
.users
|
||||
.get(&user_id)
|
||||
|
|
|
|||
Loading…
Reference in a new issue