Don't ask for master password in clean command
This commit is contained in:
parent
bdfb17d888
commit
4b15b9403a
1 changed files with 25 additions and 18 deletions
|
@ -63,26 +63,33 @@ impl Cli {
|
||||||
"Getting password file: {}",
|
"Getting password file: {}",
|
||||||
passwords_file.to_string_lossy()
|
passwords_file.to_string_lossy()
|
||||||
);
|
);
|
||||||
let password = scanpw::scanpw!("Master Password: ");
|
let password_manager = if matches!(self.command, Commands::Clean(..)) {
|
||||||
|
Passwords {
|
||||||
if password::is_new_password_file(&passwords_file)? {
|
passwords_file,
|
||||||
let analyzed = passwords::analyzer::analyze(&password);
|
..Default::default()
|
||||||
if analyzed.length() < 15 {
|
|
||||||
return Err(PassrsError::WeakPassword(
|
|
||||||
"The password length must be beggier then 15".to_owned(),
|
|
||||||
));
|
|
||||||
} else if passwords::scorer::score(&analyzed) < 80.0 {
|
|
||||||
return Err(PassrsError::WeakPassword(
|
|
||||||
"Your password is not stronge enough".to_owned(),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
let password = scanpw::scanpw!("Master Password: ");
|
||||||
|
|
||||||
let master_password = sha256::digest(password);
|
if password::is_new_password_file(&passwords_file)? {
|
||||||
let password_manager = Passwords::try_reload(
|
let analyzed = passwords::analyzer::analyze(&password);
|
||||||
passwords_file,
|
if analyzed.length() < 15 {
|
||||||
master_password.into_bytes().into_iter().take(32).collect(),
|
return Err(PassrsError::WeakPassword(
|
||||||
)?;
|
"The password length must be beggier then 15".to_owned(),
|
||||||
|
));
|
||||||
|
} else if passwords::scorer::score(&analyzed) < 80.0 {
|
||||||
|
return Err(PassrsError::WeakPassword(
|
||||||
|
"Your password is not stronge enough".to_owned(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let master_password = sha256::digest(password);
|
||||||
|
Passwords::try_reload(
|
||||||
|
passwords_file,
|
||||||
|
master_password.into_bytes().into_iter().take(32).collect(),
|
||||||
|
)?
|
||||||
|
};
|
||||||
self.command.run(password_manager)?;
|
self.command.run(password_manager)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue