diff --git a/src/handlers.rs b/src/handlers.rs index 8f12c87..17a5ada 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -88,7 +88,7 @@ pub async fn post_edit_signup( } /// Called from Stripe with the receipt of payment. -pub async fn signup_success(session: Session, receipt: Option>) -> impl IntoResponse { +pub async fn payment_success(session: Session, receipt: Option>) -> impl IntoResponse { let user: User = session.get(SIGNUP_KEY).await.unwrap().unwrap_or_default(); if user == User::default() { return SignupErrorPage("who you?".to_string()).into_response(); diff --git a/src/main.rs b/src/main.rs index cc6eeee..31c1b9f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,16 +2,13 @@ use std::net::SocketAddr; use axum::{routing::get, Router}; use tower_http::services::ServeDir; -use tower_sessions::{MemoryStore, SessionManagerLayer}; +use tower_sessions::{Expiry, MemoryStore, SessionManagerLayer}; -// "extern crate" is this olde-timey way to bring macros into the current live -// namespace; I'm not sure why it's needed here; we're using this to allow to do -// like such as #[derive(Error)] before a struct or enum. #[macro_use] extern crate justerror; mod handlers; -use handlers::{get_signup, post_signup, signup_success}; +use handlers::{get_signup, payment_success, post_signup}; mod templates; @@ -26,17 +23,19 @@ async fn main() { // just for signups let session_store = MemoryStore::default(); - let session_layer = SessionManagerLayer::new(session_store).with_secure(true); + let session_layer = SessionManagerLayer::new(session_store) + .with_secure(true) + .with_expiry(Expiry::OnInactivity(time::Duration::hours(16))); // the core application, defining the routes and handlers let app = Router::new() .nest_service("/assets", assets_svc) .route("/signup", get(get_signup).post(post_signup)) - .route("/signup_success/:receipt", get(signup_success)) + .route("/payment_success/:receipt", get(payment_success)) .layer(session_layer) .into_make_service(); - // listing on the network + // listening on the network let addr = SocketAddr::from(([127, 0, 0, 1], 3000)); let listener = tokio::net::TcpListener::bind(&addr).await.unwrap(); axum::serve(listener, app).await.unwrap();