pub async fn create_user(
pool: &Pool<MySql>,
email: &str,
password: &str,
salt: &str,
) -> Result<User>Expand description
Creates a new user in the system.
This function inserts a new user record with the provided information. New users are created with the ‘pending’ status by default.
§Arguments
pool- Database connection pool for executing the queryemail- User’s email address (must be unique)password- User’s password (should be pre-hashed for security)salt- Cryptographic salt used in the password hashing process
§Returns
Ok(User)- Successfully created user recordErr(anyhow::Error)- Failed to create user record
§Security Considerations
This function expects the password to be pre-hashed before being passed in. It does not perform any password hashing itself, as this is typically handled by a higher-level security service. Never pass plain text passwords to this function.
§Transaction Handling
This function uses a database transaction to ensure atomicity of the operation. If any part of the operation fails, the entire operation is rolled back.