pub async fn authenticate_user<'a>(
virtual_file_system: &'a VirtualFileSystem<'a>,
user_name: &str,
password: &str,
) -> Result<UserIdentifier>
Expand description
Authenticates a user with their username and password.
This function reads the user’s file from the filesystem, compares the provided password hash with the stored hash, and returns the user’s identifier if authentication succeeds.
§Arguments
Virtual_file_system
- Reference to the virtual file systemUser_name
- Username to authenticatePassword
- Plain text password to verify
§Returns
Returns Ok(User_identifier_type)
if authentication succeeds,
or an appropriate error if authentication fails or file operations fail.
§Errors
Failed_to_get_user_file_path
- Invalid username or path construction failureFailed_to_open_user_file
- User file doesn’t exist or permission deniedFailed_to_read_user_file
- I/O error reading user fileFailed_to_parse_user_file
- Invalid JSON format in user fileInvalid_password
- Password doesn’t match stored hash