aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-04-18 02:34:58 -0400
committerJesse Luehrs <doy@tozt.net>2020-04-18 02:34:58 -0400
commit0402e161b1a3b69af3cc8ede2fcaf1c4855b601b (patch)
tree0151b636301bd010c746b5b2730855ef30708f93
parent45343bb64d9230da0705d259c7f411d8af8d990f (diff)
downloadrbw-0402e161b1a3b69af3cc8ede2fcaf1c4855b601b.tar.gz
rbw-0402e161b1a3b69af3cc8ede2fcaf1c4855b601b.zip
support adding entries with notes
-rw-r--r--src/api.rs11
-rw-r--r--src/bin/rbw/commands.rs12
2 files changed, 11 insertions, 12 deletions
diff --git a/src/api.rs b/src/api.rs
index b5502e6..7ff0a8c 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -150,6 +150,8 @@ pub struct Cipher {
pub name: String,
#[serde(rename = "Login")]
pub login: Login,
+ #[serde(rename = "Notes")]
+ pub notes: Option<String>,
}
#[derive(serde::Serialize, serde::Deserialize, Debug)]
@@ -250,18 +252,13 @@ impl Client {
}
}
- pub fn add(
- &self,
- access_token: &str,
- cipher: &Cipher,
- // TODO: note
- ) -> Result<()> {
+ pub fn add(&self, access_token: &str, cipher: &Cipher) -> Result<()> {
let req = CiphersPostReq {
ty: 1,
folder_id: None,
organization_id: None,
name: cipher.name.clone(),
- notes: None,
+ notes: cipher.notes.clone(),
favorite: false,
login: CiphersPostReqLogin {
uri: None,
diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs
index a42e796..3e2f241 100644
--- a/src/bin/rbw/commands.rs
+++ b/src/bin/rbw/commands.rs
@@ -148,18 +148,18 @@ pub fn add(name: &str, username: Option<&str>) -> anyhow::Result<()> {
let password = lines.next().unwrap();
let password = crate::actions::encrypt(password)?;
- let mut note: String = lines
+ let mut notes: String = lines
.skip_while(|line| *line == "")
.filter(|line| !line.starts_with('#'))
.map(|line| format!("{}\n", line))
.collect();
- while note.ends_with('\n') {
- note.pop();
+ while notes.ends_with('\n') {
+ notes.pop();
}
- let note = if note == "" {
+ let notes = if notes == "" {
None
} else {
- Some(crate::actions::encrypt(&note)?)
+ Some(crate::actions::encrypt(&notes)?)
};
let cipher = rbw::api::Cipher {
@@ -168,6 +168,7 @@ pub fn add(name: &str, username: Option<&str>) -> anyhow::Result<()> {
username,
password: Some(password),
},
+ notes,
};
let res = rbw::actions::add(&access_token, &cipher);
@@ -222,6 +223,7 @@ pub fn generate(
username,
password: Some(password),
},
+ notes: None,
};
let res = rbw::actions::add(&access_token, &cipher);