From b94f4db52a2baa6010f7baa4181dd582c2ff5f6b Mon Sep 17 00:00:00 2001 From: Miroslav Prasil Date: Tue, 13 Nov 2018 15:34:37 +0000 Subject: [PATCH] Fix #242 --- src/api/core/ciphers.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/api/core/ciphers.rs b/src/api/core/ciphers.rs index d86e41dc..6a2ecd5a 100644 --- a/src/api/core/ciphers.rs +++ b/src/api/core/ciphers.rs @@ -132,9 +132,18 @@ pub struct CipherData { } #[post("/ciphers/admin", data = "")] -fn post_ciphers_admin(data: JsonUpcase, headers: Headers, conn: DbConn, ws: State) -> JsonResult { - // TODO: Implement this correctly - post_ciphers(data, headers, conn, ws) +fn post_ciphers_admin(data: JsonUpcase, headers: Headers, conn: DbConn, ws: State) -> JsonResult { + let data: ShareCipherData = data.into_inner().data; + + let mut cipher = Cipher::new(data.Cipher.Type.clone(), data.Cipher.Name.clone()); + cipher.user_uuid = Some(headers.user.uuid.clone()); + match cipher.save(&conn) { + Ok(()) => (), + Err(_) => err!("Failed saving cipher") + }; + + share_cipher_by_uuid(&cipher.uuid, data, &headers, &conn, &ws) + } #[post("/ciphers", data = "")]