create_user

Function create_user 

Source
pub async fn create_user(
    __arg0: State<Arc<AppState>>,
    __arg1: Json<UserCreateScheme>,
) -> Result<impl IntoResponse, (StatusCode, Json<Value>)>
Expand description

Registers a new user in the system.

Creates a new User account with the provided UserCreateScheme credentials. The password is hashed using Argon2 before being stored. Only administrators can create new users.

§Arguments

  • State(data): Application state containing AppState for database access
  • request: UserCreateScheme containing user details including first/last name, username, admin flag, and password

§Returns

  • 200 OK on successful user creation
  • 400 Bad Request if username/password missing or user already exists
  • 500 Internal Server Error if database insertion fails

§Password Hashing

Uses Argon2 with a cryptographically secure random salt.