diff --git a/src/main.rs b/src/main.rs index af610b5..e3da23a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,19 @@ +mod auth; mod tui; -fn main() -> std::io::Result<()> { +use std::io; + +fn main() -> io::Result<()> { let (username, password) = tui::run()?; - println!("user = {username}"); - println!("pass = {password}"); + match auth::authenticate(&username, &password) { + Ok(()) => { + println!("authentication successful"); + } + Err(_) => { + println!("authentication failed"); + } + } Ok(()) } diff --git a/src/tui.rs b/src/tui.rs index d11ec6a..6580cfd 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -36,7 +36,7 @@ pub fn run() -> io::Result<(String, String)> { let user = Paragraph::new(username.as_str()) .block(Block::default().borders(Borders::ALL).title("User")) .style(if focus == 0 { - Style::new().fg(Color::from_u32(0x00235759)) + Style::new().fg(Color::from_u32(0x00_235759)) } else { Style::default() }); @@ -44,7 +44,7 @@ pub fn run() -> io::Result<(String, String)> { let pass = Paragraph::new(password.as_str()) .block(Block::default().borders(Borders::ALL).title("Password")) .style(if focus == 1 { - Style::new().fg(Color::from_u32(0x00235759)) + Style::new().fg(Color::from_u32(0x00_235759)) } else { Style::default() }); @@ -57,7 +57,12 @@ pub fn run() -> io::Result<(String, String)> { match key.code { KeyCode::Esc => break, KeyCode::Tab => focus = (focus + 1) % 2, - KeyCode::Enter => break, + KeyCode::Enter => { + if !username.is_empty() && !password.is_empty() { + break; + } + } + KeyCode::Backspace => { if focus == 0 { username.pop();