fix warnings
This commit is contained in:
@@ -115,7 +115,7 @@ impl FileSystemStorageMediator {
|
||||
|
||||
/// Overload para implementar inicialización diferida con repository placeholder
|
||||
pub fn new_with_lazy_folder(
|
||||
folder_repository: Arc<RwLock<Option<Arc<dyn FolderRepository>>>>,
|
||||
_folder_repository: Arc<RwLock<Option<Arc<dyn FolderRepository>>>>,
|
||||
path_service: Arc<PathService>,
|
||||
id_mapping: Arc<dyn IdMappingPort>
|
||||
) -> Self {
|
||||
|
||||
+1
-11
@@ -523,17 +523,7 @@ impl Default for AppState {
|
||||
}
|
||||
}
|
||||
|
||||
struct DummyFilePathResolutionPort;
|
||||
#[async_trait::async_trait]
|
||||
impl crate::application::ports::storage_ports::FilePathResolutionPort for DummyFilePathResolutionPort {
|
||||
async fn get_file_path(&self, _id: &str) -> Result<crate::domain::services::path_service::StoragePath, crate::common::errors::DomainError> {
|
||||
Ok(crate::domain::services::path_service::StoragePath::from_string("/"))
|
||||
}
|
||||
|
||||
fn resolve_path(&self, _storage_path: &crate::domain::services::path_service::StoragePath) -> std::path::PathBuf {
|
||||
std::path::PathBuf::from("/")
|
||||
}
|
||||
}
|
||||
// File path resolution is handled by other components
|
||||
|
||||
struct DummyI18nService;
|
||||
#[async_trait::async_trait]
|
||||
|
||||
@@ -163,7 +163,7 @@ impl FileReadPort for FileFsReadRepository {
|
||||
})
|
||||
}
|
||||
|
||||
async fn list_files(&self, folder_id: Option<&str>) -> Result<Vec<File>, DomainError> {
|
||||
async fn list_files(&self, _folder_id: Option<&str>) -> Result<Vec<File>, DomainError> {
|
||||
// Implementación real debe obtener la lista de archivos en una carpeta
|
||||
// Por ahora, devolvemos lista vacía
|
||||
Ok(Vec::new())
|
||||
@@ -180,14 +180,14 @@ impl FileReadPort for FileFsReadRepository {
|
||||
})?;
|
||||
|
||||
// Ruta absoluta del archivo
|
||||
let abs_path = self.path_resolver.resolve_storage_path(file.storage_path());
|
||||
let _abs_path = self.path_resolver.resolve_storage_path(file.storage_path());
|
||||
|
||||
// Implementación real debe leer el contenido del archivo
|
||||
// Por ahora, devolvemos un vector vacío
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
async fn get_file_stream(&self, id: &str) -> Result<Box<dyn Stream<Item = Result<Bytes, std::io::Error>> + Send>, DomainError> {
|
||||
async fn get_file_stream(&self, _id: &str) -> Result<Box<dyn Stream<Item = Result<Bytes, std::io::Error>> + Send>, DomainError> {
|
||||
// Implementación real debe devolver un stream de bytes del archivo
|
||||
// Por ahora, lanzamos un error
|
||||
Err(DomainError::internal_error("File stream", "Stream functionality not yet implemented"))
|
||||
|
||||
@@ -50,7 +50,7 @@ impl UserRepository for UserPgRepository {
|
||||
let role_str = user.role().to_string();
|
||||
|
||||
// Modificar el SQL para hacer un cast explícito al tipo auth.userrole
|
||||
let result = sqlx::query(
|
||||
let _result = sqlx::query(
|
||||
r#"
|
||||
INSERT INTO auth.users (
|
||||
id, username, email, password_hash, role,
|
||||
|
||||
@@ -86,34 +86,7 @@ async fn login(
|
||||
// Add detailed logging for debugging
|
||||
tracing::info!("Login attempt for user: {}", dto.username);
|
||||
|
||||
// Hardcoded special case for the registered user "torrefacto" - EMERGENCY BYPASS
|
||||
// This is to allow immediate testing without database authentication issues
|
||||
if dto.username == "torrefacto" {
|
||||
tracing::info!("Using EMERGENCY BYPASS for user: torrefacto");
|
||||
|
||||
// Create a mock response using the actual registered user info
|
||||
let now = chrono::Utc::now();
|
||||
let mock_response = AuthResponseDto {
|
||||
user: UserDto {
|
||||
id: "b2f7d91b-6b44-4601-8472-f4e520879f20".to_string(), // Real user ID from database
|
||||
username: "torrefacto".to_string(),
|
||||
email: "dionisio@gmail.com".to_string(),
|
||||
role: "user".to_string(),
|
||||
active: true,
|
||||
storage_quota_bytes: 1024 * 1024 * 1024, // 1GB
|
||||
storage_used_bytes: 0,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
last_login_at: Some(now),
|
||||
},
|
||||
access_token: "torrefacto-emergency-access-token".to_string(),
|
||||
refresh_token: "torrefacto-emergency-refresh-token".to_string(),
|
||||
token_type: "Bearer".to_string(),
|
||||
expires_in: 3600 * 24, // 24 hours
|
||||
};
|
||||
|
||||
return Ok((StatusCode::OK, Json(mock_response)));
|
||||
}
|
||||
// Normal login process
|
||||
|
||||
// Verify auth service exists
|
||||
let auth_service = match state.auth_service.as_ref() {
|
||||
@@ -182,35 +155,7 @@ async fn refresh_token(
|
||||
State(state): State<Arc<AppState>>,
|
||||
Json(dto): Json<RefreshTokenDto>,
|
||||
) -> Result<impl IntoResponse, AppError> {
|
||||
// EMERGENCY BYPASS for torrefacto user
|
||||
if dto.refresh_token == "torrefacto-emergency-refresh-token" {
|
||||
tracing::info!("Using EMERGENCY BYPASS for refresh token");
|
||||
|
||||
// Create a mock response using the actual registered user info
|
||||
let now = chrono::Utc::now();
|
||||
let mock_response = AuthResponseDto {
|
||||
user: UserDto {
|
||||
id: "b2f7d91b-6b44-4601-8472-f4e520879f20".to_string(), // Real user ID from database
|
||||
username: "torrefacto".to_string(),
|
||||
email: "dionisio@gmail.com".to_string(),
|
||||
role: "user".to_string(),
|
||||
active: true,
|
||||
storage_quota_bytes: 1024 * 1024 * 1024, // 1GB
|
||||
storage_used_bytes: 0,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
last_login_at: Some(now),
|
||||
},
|
||||
access_token: "torrefacto-emergency-access-token-new".to_string(),
|
||||
refresh_token: "torrefacto-emergency-refresh-token-new".to_string(),
|
||||
token_type: "Bearer".to_string(),
|
||||
expires_in: 3600 * 24, // 24 hours
|
||||
};
|
||||
|
||||
return Ok((StatusCode::OK, Json(mock_response)));
|
||||
}
|
||||
|
||||
// Normal process for other tokens
|
||||
// Normal process for all tokens
|
||||
let auth_service = state.auth_service.as_ref()
|
||||
.ok_or_else(|| AppError::internal_error("Servicio de autenticación no configurado"))?;
|
||||
|
||||
@@ -223,29 +168,7 @@ async fn get_current_user(
|
||||
State(state): State<Arc<AppState>>,
|
||||
Extension(current_user): Extension<CurrentUser>,
|
||||
) -> Result<impl IntoResponse, AppError> {
|
||||
// EMERGENCY BYPASS for torrefacto user
|
||||
if current_user.id == "b2f7d91b-6b44-4601-8472-f4e520879f20" || current_user.username == "torrefacto" {
|
||||
tracing::info!("Using EMERGENCY BYPASS for get_current_user with torrefacto");
|
||||
|
||||
// Create a mock response with the actual registered user info
|
||||
let now = chrono::Utc::now();
|
||||
let user_dto = UserDto {
|
||||
id: "b2f7d91b-6b44-4601-8472-f4e520879f20".to_string(),
|
||||
username: "torrefacto".to_string(),
|
||||
email: "dionisio@gmail.com".to_string(),
|
||||
role: "user".to_string(),
|
||||
active: true,
|
||||
storage_quota_bytes: 1024 * 1024 * 1024, // 1GB
|
||||
storage_used_bytes: 0,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
last_login_at: Some(now),
|
||||
};
|
||||
|
||||
return Ok((StatusCode::OK, Json(user_dto)));
|
||||
}
|
||||
|
||||
// Normal process for other users
|
||||
// Normal process for all users
|
||||
let auth_service = state.auth_service.as_ref()
|
||||
.ok_or_else(|| AppError::internal_error("Servicio de autenticación no configurado"))?;
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ impl FolderHandler {
|
||||
/// Deletes a folder with trash functionality
|
||||
pub async fn delete_folder_with_trash(
|
||||
State(state): State<GlobalAppState>,
|
||||
auth_user: AuthUser,
|
||||
_auth_user: AuthUser,
|
||||
Path(id): Path<String>,
|
||||
) -> impl IntoResponse {
|
||||
// Check if trash service is available
|
||||
|
||||
@@ -292,7 +292,7 @@ pub fn create_api_routes(
|
||||
.nest("/search", search_router);
|
||||
|
||||
// Re-enable trash routes to make the trash view work
|
||||
if let Some(trash_service_ref) = trash_service.clone() {
|
||||
if let Some(_trash_service_ref) = trash_service.clone() {
|
||||
tracing::info!("Setting up trash routes for trash view");
|
||||
|
||||
// Create a router for trash specific endpoints that handles the auth requirements
|
||||
@@ -534,7 +534,7 @@ pub fn create_api_routes(
|
||||
}
|
||||
|
||||
// Get the app configuration
|
||||
let config = AppConfig::from_env();
|
||||
let _config = AppConfig::from_env();
|
||||
|
||||
// For now, just use the router as is - we'll properly implement the auth middleware later
|
||||
// when all implementation details are fixed
|
||||
|
||||
@@ -80,33 +80,18 @@ pub async fn get_auth_user(req: &Request<Body>) -> Result<AuthUser, AuthError> {
|
||||
|
||||
// Middleware de autenticación simplificado - solo valida si existe un token
|
||||
pub async fn auth_middleware(
|
||||
State(state): State<Arc<AppState>>,
|
||||
State(_state): State<Arc<AppState>>,
|
||||
headers: HeaderMap,
|
||||
mut request: Request,
|
||||
next: Next,
|
||||
) -> Result<Response, AuthError> {
|
||||
// En una primera etapa, simplemente verificar si hay un token, sin validarlo
|
||||
if let Some(token_str) = headers
|
||||
if let Some(_token_str) = headers
|
||||
.get(header::AUTHORIZATION)
|
||||
.and_then(|value| value.to_str().ok())
|
||||
.and_then(|value| value.strip_prefix("Bearer ")) {
|
||||
|
||||
// EMERGENCY BYPASS for torrefacto user
|
||||
if token_str == "torrefacto-emergency-access-token" || token_str == "torrefacto-emergency-access-token-new" {
|
||||
tracing::info!("Using EMERGENCY BYPASS in auth middleware for torrefacto token");
|
||||
|
||||
// Create a user with the actual registered user info
|
||||
let current_user = CurrentUser {
|
||||
id: "b2f7d91b-6b44-4601-8472-f4e520879f20".to_string(),
|
||||
username: "torrefacto".to_string(),
|
||||
email: "dionisio@gmail.com".to_string(),
|
||||
role: "user".to_string(),
|
||||
};
|
||||
|
||||
// Add user to the request
|
||||
request.extensions_mut().insert(current_user);
|
||||
return Ok(next.run(request).await);
|
||||
}
|
||||
// Process token normally
|
||||
|
||||
// For regular tokens, create a test user (this will be replaced with real validation)
|
||||
let current_user = CurrentUser {
|
||||
|
||||
Reference in New Issue
Block a user