Skip to content

Commit

Permalink
also delete organization_api_key (dani-garcia#4557)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan0xC authored May 19, 2024
1 parent 3261534 commit f5fb69b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/db/models/organization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ impl Organization {
UserOrganization::delete_all_by_organization(&self.uuid, conn).await?;
OrgPolicy::delete_all_by_organization(&self.uuid, conn).await?;
Group::delete_all_by_organization(&self.uuid, conn).await?;
OrganizationApiKey::delete_all_by_organization(&self.uuid, conn).await?;

db_run! { conn: {
diesel::delete(organizations::table.filter(organizations::uuid.eq(self.uuid)))
Expand Down Expand Up @@ -886,6 +887,14 @@ impl OrganizationApiKey {
.ok().from_db()
}}
}

pub async fn delete_all_by_organization(org_uuid: &str, conn: &mut DbConn) -> EmptyResult {
db_run! { conn: {
diesel::delete(organization_api_key::table.filter(organization_api_key::org_uuid.eq(org_uuid)))
.execute(conn)
.map_res("Error removing organization api key from organization")
}}
}
}

#[cfg(test)]
Expand Down

0 comments on commit f5fb69b

Please sign in to comment.