mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-09-12 19:45:58 +03:00
Delete folder mappings when deleting folders and make sure that we can't change a ciphers owner when created
This commit is contained in:
@@ -36,7 +36,7 @@ pub struct Cipher {
|
||||
|
||||
/// Local methods
|
||||
impl Cipher {
|
||||
pub fn new(user_uuid: Option<String>, organization_uuid: Option<String>, type_: i32, name: String, favorite: bool) -> Self {
|
||||
pub fn new(type_: i32, name: String) -> Self {
|
||||
let now = Utc::now().naive_utc();
|
||||
|
||||
Self {
|
||||
@@ -44,11 +44,11 @@ impl Cipher {
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
|
||||
user_uuid,
|
||||
organization_uuid,
|
||||
user_uuid: None,
|
||||
organization_uuid: None,
|
||||
|
||||
type_,
|
||||
favorite,
|
||||
favorite: false,
|
||||
name,
|
||||
|
||||
notes: None,
|
||||
@@ -98,6 +98,7 @@ impl Cipher {
|
||||
"OrganizationId": self.organization_uuid,
|
||||
"Attachments": attachments_json,
|
||||
"OrganizationUseTotp": false,
|
||||
"CollectionIds": [],
|
||||
|
||||
"Name": self.name,
|
||||
"Notes": self.notes,
|
||||
|
@@ -123,4 +123,10 @@ impl FolderCipher {
|
||||
.filter(folders_ciphers::cipher_uuid.eq(cipher_uuid))
|
||||
.first::<Self>(&**conn).ok()
|
||||
}
|
||||
|
||||
pub fn find_by_folder(folder_uuid: &str, conn: &DbConn) -> Vec<Self> {
|
||||
folders_ciphers::table
|
||||
.filter(folders_ciphers::folder_uuid.eq(folder_uuid))
|
||||
.load::<Self>(&**conn).expect("Error loading folders")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user