login improvements

This commit is contained in:
filipriec
2025-03-27 12:27:43 +01:00
parent b408abe8c6
commit d4efdf4833
2 changed files with 143 additions and 23 deletions

View File

@@ -6,6 +6,8 @@ pub struct AuthState {
pub username: String,
pub password: String,
pub error_message: Option<String>,
pub current_field: usize,
pub current_cursor_pos: usize,
}
impl AuthState {
@@ -15,6 +17,25 @@ impl AuthState {
username: String::new(),
password: String::new(),
error_message: None,
current_field: 0,
current_cursor_pos: 0,
}
}
pub fn get_current_input_mut(&mut self) -> &mut String {
match self.current_field {
0 => &mut self.username,
1 => &mut self.password,
_ => panic!("Invalid current_field in AuthState"),
}
}
pub fn get_current_input(&self) -> &str {
match self.current_field {
0 => &self.username,
1 => &self.password,
_ => panic!("Invalid current_field in AuthState"),
}
}
}