Fix warnings and change ApiError::AlreadyLoggedIn to 409 which is more correct than a 400

This commit is contained in:
Mika 2025-06-15 21:49:19 +02:00
parent 50c17393e2
commit 1cf32cfea2
4 changed files with 14 additions and 8 deletions

View file

@ -1,7 +1,11 @@
use super::Database;
impl Database {
async fn add_user_to_group(&self) {}
async fn add_user_to_group(&self) {
todo!("Implement add_user_to_group method");
}
async fn create_group(&self) {}
async fn create_group(&self) {
todo!("Implement create_group method");
}
}

View file

@ -94,7 +94,10 @@ impl Database {
let password_hash = PasswordHash::new(&local_auth.hash)
.map_err(|err| ApiError::Argon2Error(err.to_string()))?;
if let Err(_) = argon2.verify_password(password.as_bytes(), &password_hash) {
if argon2
.verify_password(password.as_bytes(), &password_hash)
.is_err()
{
return Err(ApiError::Unauthorized);
}

View file

@ -34,7 +34,7 @@ impl ResponseError for ApiError {
ApiError::ValidationError(..) => StatusCode::BAD_REQUEST,
ApiError::Argon2Error(..) => StatusCode::INTERNAL_SERVER_ERROR,
ApiError::SessionInsertError(..) => StatusCode::INTERNAL_SERVER_ERROR,
ApiError::AlreadyLoggedIn => StatusCode::BAD_REQUEST,
ApiError::AlreadyLoggedIn => StatusCode::CONFLICT,
}
}

View file

@ -120,11 +120,10 @@ async fn connect_to_redis_database() -> RedisSessionStore {
.map(|x| x.parse::<u16>().expect("REDIS_PORT is not a valid port"))
.unwrap_or(6379);
let redis_connection_string = format!("redis://{}:{}", redis_host, redis_port);
let store = RedisSessionStore::new(redis_connection_string)
.await
.unwrap();
store
RedisSessionStore::new(redis_connection_string)
.await
.unwrap()
}
fn build_database_url() -> String {