// Libraries use std::{io, process::exit}; // Functions 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); } 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); } }