use api::http::Router; use api::http::routing::{delete, get, post, put}; use crate::AuthService; use crate::handlers::accept_agreement::accept_agreement; use crate::handlers::agreement_page::agreement_page; use crate::handlers::create_report::create_report; use crate::handlers::delete_notification::delete_notification; use crate::handlers::get_preferences::get_preferences; use crate::handlers::get_user::get_user; use crate::handlers::list_agreements::list_agreements; use crate::handlers::list_notifications::list_notifications; use crate::handlers::me::me; use crate::handlers::unread_notifications_count::unread_notifications_count; use crate::handlers::update_preferences::update_preferences; use crate::handlers::update_profile::update_profile; use crate::handlers::users; pub fn public(_service: AuthService) -> Router { Router::::new() .route( "/auth/challenge", post(crate::handlers::challenge::challenge), ) .route("/auth/login", post(crate::handlers::login::login)) .route("/auth/login/code", post(crate::handlers::login::login_code)) .route( "/auth/login/code/verify", post(crate::handlers::login::login_code_verify), ) .route( "/auth/login/verify", post(crate::handlers::login::login_verify), ) .route("/auth/logout", post(crate::handlers::logout::logout)) .route("/auth/me", get(crate::handlers::identity_me::me)) .route( "/auth/register/code", post(crate::handlers::register::register_code), ) .route("/auth/register", post(crate::handlers::register::register)) .route( "/auth/password/reset", post(crate::handlers::password_reset::password_reset_request), ) .route( "/auth/password/reset/confirm", post(crate::handlers::password_reset::password_reset), ) .route("/auth/agreements", get(list_agreements)) } pub fn protected(_service: AuthService) -> Router { Router::::new() .route("/users", get(users::list_users_batch)) .route( "/users/by-username/{username}", get(users::get_user_by_username), ) .route("/users/{user_id}", get(get_user)) .route("/me", get(me).patch(update_profile)) .route("/me/username", put(users::update_username)) .route( "/me/preferences", get(get_preferences).patch(update_preferences), ) .route("/me/agreements/{key}", put(accept_agreement)) .route("/me/notifications", get(list_notifications)) .route( "/me/notifications/unread-count", get(unread_notifications_count), ) .route( "/me/notifications/{notification_id}", delete(delete_notification), ) .route( "/me/notifications/read", put(crate::handlers::mark_notifications_read::mark_notifications_read), ) .route("/me/reports", post(create_report)) .route( "/auth/password/change", post(crate::handlers::password::change_password), ) .route( "/auth/2fa/status", get(crate::handlers::two_factor::totp_status), ) .route( "/auth/2fa/setup", post(crate::handlers::two_factor::totp_setup), ) .route( "/auth/2fa/enable", post(crate::handlers::two_factor::totp_enable), ) .route( "/auth/2fa/disable", post(crate::handlers::two_factor::totp_disable), ) .route( "/auth/2fa/recovery-codes", get(crate::handlers::two_factor::recovery_codes) .put(crate::handlers::two_factor::regenerate_recovery_codes), ) .route( "/me/sessions", get(crate::handlers::sessions::list_sessions) .delete(crate::handlers::sessions::revoke_all_sessions), ) .route( "/me/sessions/{session_id}", delete(crate::handlers::sessions::revoke_session), ) .route("/me/devices", get(crate::handlers::devices::list_devices)) } pub fn pages_router(service: AuthService) -> Router { Router::<()>::new() .route("/agreements/{key}", get(agreement_page)) .with_state(service) }