Manage users on admin panel
This commit is contained in:
@@ -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.");
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
@@ -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, ..
|
||||
|
||||
Reference in New Issue
Block a user