pub async fn create_account(
users_db: &Database,
instance: &Instance,
username: impl AsRef<str>,
password: &str,
) -> Result<(String, AccountInfo, PrivateKey)>Expand description
Create a new account
This function:
- Optionally hashes the account’s password (if provided)
- Generates a device keypair for the account
- Creates the portable Account database (no private keys)
- Registers AccountInfo in native local storage with a login UUID
- First-admin bootstrap: if no instance admin exists yet in
_users.auth_settings, promotes this account by adding their pubkey asAdmin(0)to the instance-admin system DBs (_usersand_databases). Subsequent accounts land as non-admins.
§Arguments
users_db- The _users system databaseinstance- The Instance handleusername- Unique username for loginpassword- Password string, including empty; all logins use encrypted bundles.
§Returns
A tuple of (login_id, AccountInfo, root_private_key). The private key is
the one just generated for this account; callers (e.g.
Instance::create_backend or
InstanceAdmin::create_account)
can hand it straight to [build_account_session] to materialise a logged-in
AccountSession without re-decrypting the key from storage.