tsk-61: Registration configuration #73
@@ -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",
|
||||
))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user