use actix_web::{HttpResponse, web}; use crate::api::response::{ApiErrorResponse, ApiResponse}; use crate::error::AppError; use crate::models::users::UserDevice; use crate::service::AppService; use crate::session::Session; /// List user devices /// /// Returns all registered devices for the authenticated user. /// Devices are sorted by last seen time (most recent first). /// Includes device metadata such as name, type, fingerprint, and trust status. /// Requires authentication. #[utoipa::path( get, path = "/api/v1/user/security/devices", tag = "User", operation_id = "userListDevices", responses( (status = 200, description = "Devices listed successfully. Returns array of device objects with metadata.", body = ApiResponse>), (status = 401, description = "Authentication required or session expired", body = ApiErrorResponse), (status = 500, description = "Internal server error", body = ApiErrorResponse), ), security( ("session_cookie" = []) ) )] pub async fn list_devices( service: web::Data, session: Session, ) -> Result { let devices = service.user.user_devices(&session).await?; Ok(HttpResponse::Ok().json(ApiResponse::new(devices))) }