Skip to content

Commit

Permalink
delete emergency access invitations
Browse files Browse the repository at this point in the history
if an invited user is deleted in the /admin panel their emergency
access invitation will remain in the database which causes
the to_json_grantee_details fn to panic
  • Loading branch information
stefan0xC committed Apr 4, 2024
1 parent 2487efa commit ce55f15
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/db/models/emergency_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ impl EmergencyAccess {
Ok(())
}

pub async fn delete_all_by_grantee_email(grantee_email: &str, conn: &mut DbConn) -> EmptyResult {
for ea in Self::find_all_invited_by_grantee_email(grantee_email, conn).await {
ea.delete(conn).await?;
}
Ok(())
}

pub async fn delete(self, conn: &mut DbConn) -> EmptyResult {
User::update_uuid_revision(&self.grantor_uuid, conn).await;

Expand Down
1 change: 1 addition & 0 deletions src/db/models/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ impl User {

Send::delete_all_by_user(&self.uuid, conn).await?;
EmergencyAccess::delete_all_by_user(&self.uuid, conn).await?;
EmergencyAccess::delete_all_by_grantee_email(&self.email, conn).await?;
UserOrganization::delete_all_by_user(&self.uuid, conn).await?;
Cipher::delete_all_by_user(&self.uuid, conn).await?;
Favorite::delete_all_by_user(&self.uuid, conn).await?;
Expand Down

0 comments on commit ce55f15

Please sign in to comment.