Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-11-26 05:50:29 +01:00
Merge pull request #14 from mprasil/shared_cipher
Also list shared ciphers in find_by_user
Dieser Commit ist enthalten in:
Commit
c29d342c21
3 geänderte Dateien mit 29 neuen und 4 gelöschten Zeilen
|
@ -168,7 +168,7 @@ fn delete_account(data: Json<PasswordData>, headers: Headers, conn: DbConn) -> E
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete ciphers and their attachments
|
// Delete ciphers and their attachments
|
||||||
for cipher in Cipher::find_by_user(&user.uuid, &conn) {
|
for cipher in Cipher::find_owned_by_user(&user.uuid, &conn) {
|
||||||
for a in Attachment::find_by_cipher(&cipher.uuid, &conn) { a.delete(&conn); }
|
for a in Attachment::find_by_cipher(&cipher.uuid, &conn) { a.delete(&conn); }
|
||||||
|
|
||||||
cipher.delete(&conn);
|
cipher.delete(&conn);
|
||||||
|
|
|
@ -503,7 +503,7 @@ fn delete_all(data: Json<PasswordData>, headers: Headers, conn: DbConn) -> Empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete ciphers and their attachments
|
// Delete ciphers and their attachments
|
||||||
for cipher in Cipher::find_by_user(&user.uuid, &conn) {
|
for cipher in Cipher::find_owned_by_user(&user.uuid, &conn) {
|
||||||
_delete_cipher(cipher, &conn);
|
_delete_cipher(cipher, &conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,32 @@ impl Cipher {
|
||||||
.first::<Self>(&**conn).ok()
|
.first::<Self>(&**conn).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Find all ciphers accesible to user
|
||||||
pub fn find_by_user(user_uuid: &str, conn: &DbConn) -> Vec<Self> {
|
pub fn find_by_user(user_uuid: &str, conn: &DbConn) -> Vec<Self> {
|
||||||
|
ciphers::table
|
||||||
|
.left_join(users_organizations::table.on(
|
||||||
|
ciphers::organization_uuid.eq(users_organizations::org_uuid.nullable()).and(
|
||||||
|
users_organizations::user_uuid.eq(user_uuid)
|
||||||
|
)
|
||||||
|
))
|
||||||
|
.left_join(ciphers_collections::table)
|
||||||
|
.left_join(users_collections::table.on(
|
||||||
|
ciphers_collections::collection_uuid.eq(users_collections::collection_uuid)
|
||||||
|
))
|
||||||
|
.filter(ciphers::user_uuid.eq(user_uuid).or( // Cipher owner
|
||||||
|
users_organizations::access_all.eq(true).or( // access_all in Organization
|
||||||
|
users_organizations::type_.le(UserOrgType::Admin as i32).or( // Org admin or owner
|
||||||
|
users_collections::user_uuid.eq(user_uuid) // Access to Collection
|
||||||
|
)
|
||||||
|
)
|
||||||
|
))
|
||||||
|
.select(ciphers::all_columns)
|
||||||
|
.distinct()
|
||||||
|
.load::<Self>(&**conn).expect("Error loading ciphers")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find all ciphers directly owned by user
|
||||||
|
pub fn find_owned_by_user(user_uuid: &str, conn: &DbConn) -> Vec<Self> {
|
||||||
ciphers::table
|
ciphers::table
|
||||||
.filter(ciphers::user_uuid.eq(user_uuid))
|
.filter(ciphers::user_uuid.eq(user_uuid))
|
||||||
.load::<Self>(&**conn).expect("Error loading ciphers")
|
.load::<Self>(&**conn).expect("Error loading ciphers")
|
||||||
|
|
Laden …
In neuem Issue referenzieren