This repository has been archived on 2026-04-25. You can view files and clone it, but cannot push or open issues or pull requests.
RustyPass/src/interface.rs

44 lines
1.2 KiB
Rust
Raw Normal View History

// Libraries
2024-06-14 13:32:02 -05:00
use std::{io, process::exit};
// Functions
2024-06-14 13:32:02 -05:00
fn get_credentials() -> (String, String) {
// Variables
let mut username: String = String::new();
let mut password: String = String::new();
// Asking for the username
println!("Username: ");
io::stdin().read_line(&mut username).expect("Failed to read line");
username = String::from(username.to_lowercase().trim());
// Asking for the password
println!("Password: ");
io::stdin().read_line(&mut password).expect("Failed to read line");
password = String::from(password.trim());
return (username, password);
2024-06-14 13:32:02 -05:00
}
pub fn int_auth() -> (String, String) {
println!(" - LOGIN - ");
return get_credentials();
}
pub fn int_reg() -> (String, String) {
// Register form
println!(" - REGISTER - ");
let (username, password) = get_credentials();
// Confirming password
let mut cpassword: String = String::new();
println!("Confirm Password: ");
io::stdin().read_line(&mut cpassword).expect("Failed to read line");
cpassword = String::from(cpassword.trim());
// Valid password?
if password != cpassword {
println!("Passwords do not match!");
exit(0);
} else {
return (username, password);
}
}