From 44f0f76c906d3fabe592958c208c0782a1d9305a Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 19 Apr 2020 20:26:35 -0400 Subject: allow creating entries with associated uris --- src/bin/rbw/commands.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/bin/rbw/commands.rs') diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs index 839dca3..2385163 100644 --- a/src/bin/rbw/commands.rs +++ b/src/bin/rbw/commands.rs @@ -129,7 +129,11 @@ pub fn get(name: &str, user: Option<&str>, full: bool) -> anyhow::Result<()> { Ok(()) } -pub fn add(name: &str, username: Option<&str>) -> anyhow::Result<()> { +pub fn add( + name: &str, + username: Option<&str>, + uris: Vec<&str>, +) -> anyhow::Result<()> { unlock()?; let email = config_email()?; @@ -154,6 +158,10 @@ pub fn add(name: &str, username: Option<&str>) -> anyhow::Result<()> { let notes = notes .map(|notes| crate::actions::encrypt(¬es)) .transpose()?; + let uris: Vec = uris + .iter() + .map(|uri| crate::actions::encrypt(&uri)) + .collect::>()?; if let (Some(access_token), ()) = rbw::actions::add( &access_token, @@ -162,6 +170,7 @@ pub fn add(name: &str, username: Option<&str>) -> anyhow::Result<()> { username.as_deref(), password.as_deref(), notes.as_deref(), + &uris, )? { db.access_token = Some(access_token); db.save(&email).context("failed to save database")?; @@ -175,6 +184,7 @@ pub fn add(name: &str, username: Option<&str>) -> anyhow::Result<()> { pub fn generate( name: Option<&str>, username: Option<&str>, + uris: Vec<&str>, len: usize, ty: rbw::pwgen::Type, ) -> anyhow::Result<()> { @@ -196,6 +206,10 @@ pub fn generate( .map(|username| crate::actions::encrypt(username)) .transpose()?; let password = crate::actions::encrypt(&password)?; + let uris: Vec = uris + .iter() + .map(|uri| crate::actions::encrypt(&uri)) + .collect::>()?; if let (Some(access_token), ()) = rbw::actions::add( &access_token, @@ -204,6 +218,7 @@ pub fn generate( username.as_deref(), Some(&password), None, + &uris, )? { db.access_token = Some(access_token); db.save(&email).context("failed to save database")?; -- cgit v1.2.3-54-g00ecf