Manage users on admin panel
Some checks failed
Rust / Test (push) Failing after 4m18s
Rust / Rustfmt (push) Successful in 22s
Rust / Clippy (push) Failing after 1m39s
Rust / Code coverage (push) Successful in 4m25s

This commit is contained in:
Alphonse Paix
2025-10-02 22:13:02 +02:00
parent 91e80b4881
commit 96e5dd0f35
12 changed files with 324 additions and 35 deletions

View File

@@ -56,7 +56,7 @@ pub async fn change_password(
}
}
fn verify_password(password: &str) -> Result<(), anyhow::Error> {
pub fn verify_password(password: &str) -> Result<(), anyhow::Error> {
if password.len() < 12 || password.len() > 128 {
anyhow::bail!("The password must contain between 12 and 128 characters.");
}

View File

@@ -1,3 +1,4 @@
use crate::routes::get_users;
use crate::{
authentication::AuthenticatedUser,
routes::{AppError, get_max_page, get_subs, get_total_subs},
@@ -45,6 +46,9 @@ pub async fn admin_dashboard(
.await
.context("Could not fetch total subscribers count from the database.")?;
let max_page = get_max_page(count);
let users = get_users(&connection_pool)
.await
.context("Could not fetch users")?;
let template = DashboardTemplate {
user,
idempotency_key_1,
@@ -53,6 +57,7 @@ pub async fn admin_dashboard(
subscribers,
current_page,
max_page,
users,
};
Ok(Html(template.render().unwrap()).into_response())
}

View File

@@ -15,10 +15,7 @@ use uuid::Uuid;
const SUBS_PER_PAGE: i64 = 5;
#[tracing::instrument(
name = "Retrieving most recent subscribers from database",
skip(connection_pool)
)]
#[tracing::instrument(name = "Retrieving subscribers from database", skip(connection_pool))]
pub async fn get_subscribers_page(
State(AppState {
connection_pool, ..