From 2f6b506710bcdfa2c064455621771278490ecbb8 Mon Sep 17 00:00:00 2001 From: theycallmesteve <59837464+theycallmesteve@users.noreply.github.com> Date: Fri, 8 May 2020 13:41:37 -0400 Subject: [PATCH] Require a collection when adding a cipher to an organization --- src/api/core/ciphers.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/api/core/ciphers.rs b/src/api/core/ciphers.rs index 02aedc30..1231d6bd 100644 --- a/src/api/core/ciphers.rs +++ b/src/api/core/ciphers.rs @@ -208,6 +208,11 @@ fn post_ciphers_admin(data: JsonUpcase, headers: Headers, conn: fn _post_ciphers_admin(data: JsonUpcase, headers: Headers, conn: DbConn, nt: Notify, resp_model: &str) -> JsonResult { let data: ShareCipherData = data.into_inner().data; + // Require a collection, otherwise it will be saved as "Unassigned" without regard to read_only + if data.CollectionIds.is_empty() { + err!("You must select at least one collection.") + } + let mut cipher = Cipher::new(data.Cipher.Type, data.Cipher.Name.clone()); cipher.user_uuid = Some(headers.user.uuid.clone()); cipher.save(&conn)?;