Delete associated favorites when deleting a cipher or user

This prevents foreign key constraint violations.
This commit is contained in:
Jeremy Lin
2020-08-26 01:27:38 -07:00
parent 4c324e1160
commit 175d647e47
4 changed files with 108 additions and 52 deletions

View File

@@ -128,7 +128,7 @@ impl User {
}
}
use super::{Cipher, Device, Folder, TwoFactor, UserOrgType, UserOrganization};
use super::{Cipher, Device, Favorite, Folder, TwoFactor, UserOrgType, UserOrganization};
use crate::db::DbConn;
use crate::api::EmptyResult;
@@ -205,6 +205,7 @@ impl User {
UserOrganization::delete_all_by_user(&self.uuid, conn)?;
Cipher::delete_all_by_user(&self.uuid, conn)?;
Favorite::delete_all_by_user(&self.uuid, conn)?;
Folder::delete_all_by_user(&self.uuid, conn)?;
Device::delete_all_by_user(&self.uuid, conn)?;
TwoFactor::delete_all_by_user(&self.uuid, conn)?;