Function authenticate_user

Source
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 system
  • User_name - Username to authenticate
  • Password - 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 failure
  • Failed_to_open_user_file - User file doesn’t exist or permission denied
  • Failed_to_read_user_file - I/O error reading user file
  • Failed_to_parse_user_file - Invalid JSON format in user file
  • Invalid_password - Password doesn’t match stored hash