Skip to main content

max / makenotwork

1.3 KB · 41 lines History Blame Raw
1 //! Handlers triggered by clicking email links, plus the forms that initiate them.
2
3 mod account;
4 mod links;
5 mod password;
6
7 use axum::{routing::get, Router};
8 use tower_governor::GovernorLayer;
9
10 use crate::{constants, helpers::rate_limiter_ms, AppState};
11
12 /// Register email action routes.
13 pub fn email_action_routes() -> Router<AppState> {
14 let auth_rate_limit =
15 rate_limiter_ms(constants::AUTH_RATE_LIMIT_MS, constants::AUTH_RATE_LIMIT_BURST);
16
17 Router::new()
18 .route(
19 "/forgot-password",
20 get(password::forgot_password_page)
21 .post(password::forgot_password_handler)
22 .route_layer(GovernorLayer {
23 config: auth_rate_limit,
24 }),
25 )
26 .route(
27 "/reset-password",
28 get(password::reset_password_page).post(password::reset_password_handler),
29 )
30 .route("/verify-email", get(links::verify_email_handler))
31 .route("/login-link", get(links::login_link_handler))
32 .route(
33 "/confirm-delete",
34 get(account::confirm_delete_page).post(account::confirm_delete_handler),
35 )
36 .route(
37 "/unsubscribe",
38 get(account::unsubscribe_page).post(account::unsubscribe_handler),
39 )
40 }
41