From 222b6a5666bc0f18397bc1e49e9d438047d5268c Mon Sep 17 00:00:00 2001 From: Hinton Date: Tue, 9 Jan 2024 14:12:18 +0100 Subject: [PATCH] Cleanup logic --- crates/bitwarden/src/auth/password/strength.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/crates/bitwarden/src/auth/password/strength.rs b/crates/bitwarden/src/auth/password/strength.rs index b0d0cfeb9..9544d1f79 100644 --- a/crates/bitwarden/src/auth/password/strength.rs +++ b/crates/bitwarden/src/auth/password/strength.rs @@ -1,5 +1,3 @@ -use std::collections::HashSet; - use zxcvbn::zxcvbn; const GLOBAL_INPUTS: [&str; 3] = ["bitwarden", "bit", "warden"]; @@ -9,13 +7,11 @@ pub(crate) fn password_strength( email: String, additional_inputs: Vec, ) -> u8 { - let email_parts = email_to_user_inputs(&email); - let email_ref: Vec<_> = email_parts.iter().map(String::as_str).collect(); + let mut inputs = email_to_user_inputs(&email); + inputs.extend(additional_inputs); - let mut additional_inputs: HashSet<_> = additional_inputs.iter().map(String::as_str).collect(); - additional_inputs.extend(&GLOBAL_INPUTS); - additional_inputs.extend(&email_ref); - let arr: Vec<_> = additional_inputs.into_iter().collect(); + let mut arr: Vec<_> = inputs.iter().map(String::as_str).collect(); + arr.extend(GLOBAL_INPUTS); zxcvbn(&password, &arr).map_or(0, |e| e.score()) }