Repository: evansmurithi/cloak (language: rust)

Issue:
Remove recovery codes feature
Recovery codes for 2FA should be stored securely in a vault


Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index f6ee88a..55f1b70 100644
--- a/README.md
+++ b/README.md
@@ -69,7 +69,6 @@ SUBCOMMANDS:
     delete            Delete an account
     help              Prints this message or the help of the given subcommand(s)
     list              List OTP for all accounts
-    recovery_codes    View recovery codes for an account
     view              View the OTP for an account
 ```
 
@@ -118,11 +117,6 @@ To view the help of any of the subcommands below, add `-h` or `--help`, e.g. `cl
     Account with the name 'github' does not exist. Consider adding it.
     ```
 
-- `cloak recovery_codes <account>`
-
-    This will open a file, using your preferred editor, to either save new recovery
-    codes or view existing recovery codes.
-
 ## Customization
 
 By default `cloak` stores your accounts and recovery codes inside a `.cloak/`
diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs
index e4d650c..b1badd0 100644
--- a/src/cmd/mod.rs
+++ b/src/cmd/mod.rs
@@ -1,5 +1,4 @@
 pub mod add;
 pub mod delete;
 pub mod list;
-pub mod recovery_codes;
 pub mod view;
diff --git a/src/cmd/recovery_codes.rs b/src/cmd/recovery_codes.rs
deleted file mode 100644
index e9b06a7..0000000
--- a/src/cmd/recovery_codes.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-use clap::{App, Arg, ArgMatches, SubCommand};
-use fs;
-use open;
-
-// Create arguments for `recovery_codes` subcommand
-pub fn subcommand<'a, 'b>() -> App<'a, 'b> {
-    SubCommand::with_name("recovery_codes")
-        .about("View recovery codes for an account")
-        .arg(
-            Arg::with_name("account")
-                .required(true)
-                .help("Name of the account"),
-        )
-}
-
-// Implementation for the `recovery_codes` subcommand
-pub fn run(args: &ArgMatches) {
-    let account_name = args.value_of("account").unwrap();
-    match fs::recovery_codes(account_name) {
-        Ok(file_path) => {
-            match open::that(file_path) {
-                Ok(_) => {}
-                Err(err) => eprintln!("{}", err),
-            };
-        }
-        Err(err) => eprintln!("{}", err),
-    };
-}
diff --git a/src/dirs.rs b/src/dirs.rs
index f3c83ff..5d56621 100644
--- a/src/dirs.rs
+++ b/src/dirs.rs
@@ -4,7 +4,6 @@ use std::path::{Path, PathBuf};
 
 pub struct CloakAppDirs {
     accounts_dir: PathBuf,
-    recovery_codes_dir: PathBuf,
 }
 
 impl CloakAppDirs {
@@ -15,21 +14,12 @@ impl CloakAppDirs {
             .filter(|acc_dir| acc_dir.is_absolute())
             .or_else(|| dirs_rs::home_dir().map(|d| d.join(".cloak/")))?;
 
-        let recovery_codes_dir = accounts_dir.join("recovery_codes/");
-
-        Some(CloakAppDirs {
-            accounts_dir,
-            recovery_codes_dir,
-        })
+        Some(CloakAppDirs { accounts_dir })
     }
 
     pub fn accounts_dir(&self) -> &Path {
         &self.accounts_dir
     }
-
-    pub fn recovery_codes_dir(&self) -> &Path {
-        &self.recovery_codes_dir
-    }
 }
 
 lazy_static! {
diff --git a/src/fs.rs b/src/fs.rs
index 0497e6c..55a9ac2 100644
--- a/src/fs.rs
+++ b/src/fs.rs
@@ -32,11 +32,6 @@ pub fn write(accounts: &BTreeMap<String, Account>) -> Result<()> {
     Ok(())
 }
 
-// Return the file path containing the recovery codes for the account
-pub fn recovery_codes(account_name: &str) -> Result<PathBuf> {
-    get_file_path(CLOAK_DIRS.recovery_codes_dir(), account_name)
-}
-
 // Given directory and file name, return the entire file path. If file does
 // not exist, create it
 fn get_file_path(dir: &Path, file_name: &str) -> Result<PathBuf> {
diff --git a/src/main.rs b/src/main.rs
index 727388a..d1137d9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,7 +2,6 @@
 extern crate clap;
 extern crate data_encoding;
 extern crate dirs as dirs_rs;
-extern crate open;
 extern crate ring;
 extern crate serde;
 extern crate thiserror;
@@ -30,7 +29,6 @@ fn main() {
         .subcommand(cmd::view::subcommand())
         .subcommand(cmd::list::subcommand())
         .subcommand(cmd::delete::subcommand())
-        .subcommand(cmd::recovery_codes::subcommand())
         .get_matches();
 
     match matches.subcommand() {
@@ -38,7 +36,6 @@ fn main() {
         ("view", Some(sub_m)) => cmd::view::run(&sub_m),
         ("list", Some(_)) => cmd::list::run(),
         ("delete", Some(sub_m)) => cmd::delete::run(&sub_m),
-        ("recovery_codes", Some(sub_m)) => cmd::recovery_codes::run(&sub_m),
         _ => eprintln!("No subcommand chosen. Add --help | -h to view the subcommands."),
     }
 }


Test patch: