Added GetNewMasterPass state and added restrictions on the master password
This commit is contained in:
		@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
pub mod account;
 | 
			
		||||
pub mod master_pass;
 | 
			
		||||
pub mod password_generation;
 | 
			
		||||
pub mod passwords;
 | 
			
		||||
pub mod prelude;
 | 
			
		||||
 | 
			
		||||
#[derive(thiserror::Error, Debug)]
 | 
			
		||||
 
 | 
			
		||||
@@ -50,3 +50,28 @@ fn generate_password() -> ArrayString<32> {
 | 
			
		||||
pub fn generate_passwords() -> [ArrayString<32>; 10] {
 | 
			
		||||
    array::from_fn(|_| generate_password())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[inline]
 | 
			
		||||
pub fn check_master_pass(password: &str) -> bool {
 | 
			
		||||
    if password.chars().count() < 8 {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let mut flags = PasswordFlags::empty();
 | 
			
		||||
    for char in password.chars() {
 | 
			
		||||
        if char.is_lowercase() {
 | 
			
		||||
            flags |= PasswordFlags::LOWERCASE
 | 
			
		||||
        } else if char.is_uppercase() {
 | 
			
		||||
            flags |= PasswordFlags::UPPERCASE
 | 
			
		||||
        } else if char.is_ascii_digit() {
 | 
			
		||||
            flags |= PasswordFlags::NUMBER;
 | 
			
		||||
        } else if char.is_ascii_punctuation() {
 | 
			
		||||
            flags |= PasswordFlags::SPECIAL_CHARACTER
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if flags.is_all() {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    false
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user