tsk-61: Registration configuration #73

Merged
phoenix merged 8 commits from tsk-61 into main 2025-10-20 16:48:49 +00:00
Showing only changes of commit 6ee2db43d2 - Show all commits

View File

@@ -53,15 +53,16 @@ pub async fn register_user(
Json(payload): Json<request::Request>,
) -> (StatusCode, Json<response::Response>) {
let registration_enabled = match is_registration_enabled().await {
Ok(value) => {
value
}
Ok(value) => value,
Err(err) => {
eprintln!("Error: {err:?}");
return (axum::http::StatusCode::INTERNAL_SERVER_ERROR, Json(response::Response{
return (
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
Json(response::Response {
message: String::from("Registration check failed"),
data: Vec::new()
}));
data: Vec::new(),
}),
);
}
};
@@ -130,10 +131,13 @@ pub async fn register_user(
),
}
} else {
(axum::http::StatusCode::NOT_ACCEPTABLE, Json(response::Response{
(
axum::http::StatusCode::NOT_ACCEPTABLE,
Json(response::Response {
message: String::from("Registration is not enabled"),
data: Vec::new()
}))
data: Vec::new(),
}),
)
}
}
@@ -148,6 +152,8 @@ async fn is_registration_enabled() -> Result<bool, std::io::Error> {
} else if parsed_value == "FALSE" {
Ok(false)
} else {
Err(std::io::Error::other("Could not determine value of ENABLE_REGISTRATION"))
Err(std::io::Error::other(
"Could not determine value of ENABLE_REGISTRATION",
))
}
}