pub async fn setup_initial_admin(
__arg0: State<Arc<AppState>>,
__arg1: Json<UserCreateScheme>,
) -> Result<impl IntoResponse, (StatusCode, Json<Value>)>Expand description
Creates the initial administrator account for a fresh system.
This function handles the one-time setup of the first admin User. It checks that no admin exists
before allowing creation via database count. This endpoint is only functional when the system has no administrators.
Once created, subsequent admin registrations must go through the normal create_user endpoint
with proper authorization.
§Arguments
State(data): Application state containingAppStatefor database accessrequest:UserCreateSchemecontaining user creation details (first_name, last_name, username, password)
§Returns
200 OKwith success message if admin account created400 Bad Requestif:- Admin already exists (checked via admin count)
- Username or password is empty
500 Internal Server Errorif database insertion fails
§Security Note
The password is hashed using Argon2 with a random salt before storage.