From 5b1db01fe669d3431d69d315f73f277ce32d61d2 Mon Sep 17 00:00:00 2001 From: filipriec Date: Sun, 13 Apr 2025 14:04:30 +0200 Subject: [PATCH] displaying username and username contained in the jwt now --- client/src/state/pages/auth.rs | 2 ++ client/src/tui/functions/common/login.rs | 6 +++--- common/proto/auth.proto | 1 + common/src/proto/descriptor.bin | Bin 21155 -> 21238 bytes common/src/proto/multieko2.auth.rs | 2 ++ 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/client/src/state/pages/auth.rs b/client/src/state/pages/auth.rs index 416b89c..fa6714b 100644 --- a/client/src/state/pages/auth.rs +++ b/client/src/state/pages/auth.rs @@ -22,6 +22,7 @@ pub struct AuthState { pub auth_token: Option, pub user_id: Option, pub role: Option, + pub decoded_username: Option, pub has_unsaved_changes: bool, } @@ -55,6 +56,7 @@ impl AuthState { user_id: None, role: None, has_unsaved_changes: false, + decoded_username: None, } } } diff --git a/client/src/tui/functions/common/login.rs b/client/src/tui/functions/common/login.rs index 6bcea8d..53df246 100644 --- a/client/src/tui/functions/common/login.rs +++ b/client/src/tui/functions/common/login.rs @@ -28,15 +28,18 @@ pub async fn save( auth_state.auth_token = Some(response.access_token.clone()); auth_state.user_id = Some(response.user_id.clone()); auth_state.role = Some(response.role.clone()); + auth_state.decoded_username = Some(response.username.clone()); auth_state.set_has_unsaved_changes(false); let success_message = format!( "Login Successful!\n\n\ + Username: {}\n\ Access Token: {}\n\ Token Type: {}\n\ Expires In: {}\n\ User ID: {}\n\ Role: {}", + response.username, response.access_token, response.token_type, response.expires_in, @@ -44,9 +47,6 @@ pub async fn save( response.role ); - // Use the helper method to configure and show the dialog - // TODO Implement logic for pressing menu or exit buttons, not imeplementing it now, - // need to do other more important stuff now" app_state.show_dialog( "Login Success", &success_message, diff --git a/common/proto/auth.proto b/common/proto/auth.proto index 9c5221e..de9f8bd 100644 --- a/common/proto/auth.proto +++ b/common/proto/auth.proto @@ -35,4 +35,5 @@ message LoginResponse { int32 expires_in = 3; // Expiration in seconds (86400 for 24 hours) string user_id = 4; // User's UUID in string format string role = 5; // User's role + string username = 6; } diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index 56166bc81dd70be68054b7e00b21e434d17978e8..47c106e01b0c69542836c183f65582241ced8e63 100644 GIT binary patch delta 138 zcmZ3yl=0hA#tpTiOa}!w*Nb*AGVYwrAwEx9NQ#T2v^cdWFEKY&f=z)@gEI)mpS)Cj zG3O<2E;b<+Mh3Obff8St8Pzts%gkdm=i=sKVPR%s6=GIpk>KLtVg+%)JT4fI5h%wk R4C65ad1B(5pUUnt0RYDG9CrW! delta 54 zcmV-60LlOMr2(U*0kC})0`3sAe-(%U0iBZw7oL;C7orK93kn7j1OWggvuzml0|6zo MV;r6Vvp62UG#Mol5dZ)H diff --git a/common/src/proto/multieko2.auth.rs b/common/src/proto/multieko2.auth.rs index 22bd8ff..16f7e74 100644 --- a/common/src/proto/multieko2.auth.rs +++ b/common/src/proto/multieko2.auth.rs @@ -52,6 +52,8 @@ pub struct LoginResponse { /// User's role #[prost(string, tag = "5")] pub role: ::prost::alloc::string::String, + #[prost(string, tag = "6")] + pub username: ::prost::alloc::string::String, } /// Generated client implementations. pub mod auth_service_client {