Basic unsubscribe endpoint

This commit is contained in:
Alphonse Paix
2025-09-21 17:49:31 +02:00
parent 0725b87bf2
commit 829f3e4e4f
17 changed files with 292 additions and 43 deletions

View File

@@ -5,6 +5,7 @@ mod login;
mod posts;
mod subscriptions;
mod subscriptions_confirm;
mod unsubscribe;
pub use admin::*;
use askama::Template;
@@ -16,15 +17,38 @@ pub use health_check::*;
pub use home::*;
pub use login::*;
pub use posts::*;
use rand::{Rng, distr::Alphanumeric};
use reqwest::StatusCode;
pub use subscriptions::*;
pub use subscriptions_confirm::*;
pub use unsubscribe::*;
use crate::{
authentication::AuthError,
templates::{InternalErrorTemplate, MessageTemplate, NotFoundTemplate},
};
pub fn generate_token() -> String {
let mut rng = rand::rng();
std::iter::repeat_with(|| rng.sample(Alphanumeric))
.map(char::from)
.take(25)
.collect()
}
fn error_chain_fmt(e: &impl std::error::Error, f: &mut std::fmt::Formatter) -> std::fmt::Result {
writeln!(f, "{}", e)?;
let mut current = e.source();
while let Some(cause) = current {
write!(f, "Caused by:\n\t{}", cause)?;
current = cause.source();
if current.is_some() {
writeln!(f)?;
}
}
Ok(())
}
#[derive(thiserror::Error)]
pub enum AppError {
#[error("An unexpected error was encountered.")]