pub async fn change_user_password<'a>(
virtual_file_system: &'a VirtualFileSystem<'a>,
user_name: &str,
new_password: &str,
) -> Result<()>
Expand description
Changes a user’s password by generating a new salt and hash.
This function updates a user’s password by:
- Generating a new random salt
- Hashing the new password with the salt
- Reading the existing user file
- Updating the hash and salt fields
- Writing the updated data back to the file
§Arguments
Virtual_file_system
- Reference to the virtual file systemUser_name
- Username of the account to updateNew_password
- New plain text password
§Returns
Returns Ok(())
if the password was changed successfully,
or an appropriate error if the operation fails.
§Errors
- File system errors (opening, reading, writing user file)
- Salt generation failures
- JSON parsing errors