Development Documentation (main branch) - For stable release docs, see docs.rs/eidetica

create_user

Function create_user 

Source
pub async fn create_user(
    users_db: &Database,
    instance: &Instance,
    username: impl AsRef<str>,
    password: Option<&str>,
) -> Result<(String, UserInfo)>
Expand description

Create a new user account

This function:

  1. Optionally hashes the user’s password (if provided)
  2. Generates a device keypair for the user
  3. Creates a user database for storing keys (encrypted or unencrypted)
  4. Creates UserInfo and stores it in _users database with auto-generated UUID

§Arguments

  • users_db - The _users system database
  • instance - The Instance handle
  • username - Unique username for login
  • password - Optional password. If None, creates passwordless user (instant login, no encryption)

§Returns

A tuple of (user_uuid, UserInfo) where user_uuid is the generated primary key