pub mod captcha;
pub mod email;
pub mod login;
pub mod logout;
pub mod me;
pub mod password;
pub mod register;
// pub mod totp; // 2FA disabled
pub mod ws_token;

pub fn init_auth_routes(cfg: &mut actix_web::web::ServiceConfig) {
    cfg.service(
        actix_web::web::scope("/auth")
            .route("/login", actix_web::web::post().to(login::api_auth_login))
            .route(
                "/register",
                actix_web::web::post().to(register::api_auth_register),
            )
            .route(
                "/logout",
                actix_web::web::post().to(logout::api_auth_logout),
            )
            .route(
                "/captcha",
                actix_web::web::post().to(captcha::api_auth_captcha),
            )
            .route("/me", actix_web::web::post().to(me::api_auth_me))
            .route(
                "/password/change",
                actix_web::web::post().to(password::api_user_change_password),
            )
            .route(
                "/password/reset",
                actix_web::web::post().to(password::api_user_request_password_reset),
            )
            .route(
                "/password/confirm",
                actix_web::web::post().to(password::api_user_confirm_password_reset),
            )
            // 2FA disabled {
            // .route("/2fa/enable", actix_web::web::post().to(totp::api_2fa_enable))
            // .route("/2fa/verify", actix_web::web::post().to(totp::api_2fa_verify))
            // .route("/2fa/disable", actix_web::web::post().to(totp::api_2fa_disable))
            // .route("/2fa/status", actix_web::web::post().to(totp::api_2fa_status))
            // }
            .route("/email", actix_web::web::post().to(email::api_email_get))
            .route(
                "/email/change",
                actix_web::web::post().to(email::api_email_change),
            )
            .route(
                "/email/verify",
                actix_web::web::post().to(email::api_email_verify),
            ),
    );

    // WebSocket token endpoint
    cfg.route(
        "/ws/token",
        actix_web::web::post().to(ws_token::ws_token_generate),
    );
}
