Compare commits
4 Commits
v0.6.3-mai
...
76f7bbc9e2
| Author | SHA1 | Date | |
|---|---|---|---|
|
76f7bbc9e2
|
|||
|
34687dda7d
|
|||
|
6c83e566bf
|
|||
|
b74c0fc3b0
|
@@ -76,7 +76,6 @@ jobs:
|
||||
SECRET_KEY: ${{ secrets.TOKEN_SECRET_KEY }}
|
||||
# Make SSH agent available if tests fetch private dependencies
|
||||
SSH_AUTH_SOCK: ${{ env.SSH_AUTH_SOCK }}
|
||||
ENABLE_REGISTRATION: 'TRUE'
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/icarus_models_deploy_key
|
||||
|
||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -748,7 +748,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "icarus_auth"
|
||||
version = "0.6.3"
|
||||
version = "0.6.2"
|
||||
dependencies = [
|
||||
"argon2",
|
||||
"axum",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "icarus_auth"
|
||||
version = "0.6.3"
|
||||
version = "0.6.2"
|
||||
edition = "2024"
|
||||
rust-version = "1.90"
|
||||
|
||||
|
||||
@@ -52,21 +52,7 @@ pub async fn register_user(
|
||||
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
||||
Json(payload): Json<request::Request>,
|
||||
) -> (StatusCode, Json<response::Response>) {
|
||||
let registration_enabled = match is_registration_enabled().await {
|
||||
Ok(value) => value,
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
return (
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(response::Response {
|
||||
message: String::from("Registration check failed"),
|
||||
data: Vec::new(),
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
if registration_enabled {
|
||||
if is_registration_enabled() {
|
||||
let mut user = icarus_models::user::User {
|
||||
username: payload.username.clone(),
|
||||
password: payload.password.clone(),
|
||||
@@ -131,29 +117,9 @@ pub async fn register_user(
|
||||
),
|
||||
}
|
||||
} else {
|
||||
(
|
||||
axum::http::StatusCode::NOT_ACCEPTABLE,
|
||||
Json(response::Response {
|
||||
message: String::from("Registration is not enabled"),
|
||||
data: Vec::new(),
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks to see if registration is enabled
|
||||
async fn is_registration_enabled() -> Result<bool, std::io::Error> {
|
||||
let key = String::from("ENABLE_REGISTRATION");
|
||||
let var = icarus_envy::environment::get_env(&key).await;
|
||||
let parsed_value = var.value.to_uppercase();
|
||||
|
||||
if parsed_value == "TRUE" {
|
||||
Ok(true)
|
||||
} else if parsed_value == "FALSE" {
|
||||
Ok(false)
|
||||
} else {
|
||||
Err(std::io::Error::other(
|
||||
"Could not determine value of ENABLE_REGISTRATION",
|
||||
))
|
||||
(axum::http::StatusCode::NOT_ACCEPTABLE, Json(response::Response{
|
||||
message: String::from("Registration is not enabled"),
|
||||
data:: Vec::new()
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user