diff --git a/Cargo.lock b/Cargo.lock index 37e461f..6ea6dac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -429,7 +429,6 @@ dependencies = [ "dirs 6.0.0", "dotenvy", "lazy_static", - "log", "prost", "ratatui", "serde", diff --git a/client/Cargo.toml b/client/Cargo.toml index 6cdfed7..295607a 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -12,7 +12,6 @@ crossterm = "0.28.1" dirs = "6.0.0" dotenvy = "0.15.7" lazy_static = "1.5.0" -log = "0.4.27" prost = "0.13.5" ratatui = "0.29.0" serde = { version = "1.0.218", features = ["derive"] } diff --git a/client/src/tui/functions/common/login.rs b/client/src/tui/functions/common/login.rs index d2cedd1..5a602be 100644 --- a/client/src/tui/functions/common/login.rs +++ b/client/src/tui/functions/common/login.rs @@ -36,12 +36,21 @@ pub async fn save( login_state.set_has_unsaved_changes(false); login_state.error_message = None; - let success_message = "Login Successful!".to_string(); + // Format the success message using response data + let success_message = format!( + "Login Successful!\n\n\ + Username: {}\n\ + User ID: {}\n\ + Role: {}", + response.username, + response.user_id, + response.role + ); app_state.show_dialog( "Login Success", &success_message, - vec!["OK".to_string()], + vec!["Menu".to_string(), "Exit".to_string()], DialogPurpose::LoginSuccess, ); login_state.password.clear(); diff --git a/client/src/ui/handlers/ui.rs b/client/src/ui/handlers/ui.rs index 4e42e97..9875c4e 100644 --- a/client/src/ui/handlers/ui.rs +++ b/client/src/ui/handlers/ui.rs @@ -26,7 +26,7 @@ use crate::tui::functions::common::login; // <-- Add login module import use std::time::Instant; use crossterm::cursor::SetCursorStyle; use crossterm::event as crossterm_event; -use log; // <-- Add log import +use tracing::{info, error}; pub async fn run_ui() -> Result<(), Box> { let config = Config::load()?; @@ -137,7 +137,6 @@ pub async fn run_ui() -> Result<(), Box> { // --- End Cursor Visibility Logic --- // --- 2. Check for Pending Login Action --- - // Check *after* drawing, so the loading state was rendered. if login_state.login_request_pending { // Reset the flag *before* calling save login_state.login_request_pending = false; @@ -145,27 +144,33 @@ pub async fn run_ui() -> Result<(), Box> { // Create AuthClient and call save match AuthClient::new().await { Ok(mut auth_client_instance) => { + // Call the ORIGINAL save function from the login module let save_result = login::save( &mut auth_state, &mut login_state, - &mut auth_client_instance, + &mut auth_client_instance, // Pass the new client instance &mut app_state, ).await; + + // Use tracing for logging the outcome match save_result { - Ok(msg) => log::info!("Login save result: {}", msg), - Err(e) => log::error!("Error during login save: {}", e), + // save returns Result, Ok contains the message + Ok(msg) => info!(message = %msg, "Login save result"), // Use tracing::info! + Err(e) => error!(error = %e, "Error during login save"), // Use tracing::error! } + // Note: save already handles showing the final dialog (success/failure) } Err(e) => { - // Handle connection error - app_state.show_dialog( + // Handle client connection error - show dialog directly + // Ensure flag is already false here + app_state.show_dialog( // Use show_dialog, not update_dialog_content "Login Failed", &format!("Connection Error: {}", e), vec!["OK".to_string()], - DialogPurpose::LoginFailed, + DialogPurpose::LoginFailed, // Use appropriate purpose ); login_state.error_message = Some(format!("Connection Error: {}", e)); - log::error!("Failed to create AuthClient: {}", e); + error!(error = %e, "Failed to create AuthClient"); // Use tracing::error! } } // After save runs, the state (dialog content, etc.) is updated.