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/main.rs

63 lines
1.8 KiB
Rust
Raw Normal View History

// Libraries
mod interface;
mod resource;
2024-06-15 13:23:52 -05:00
mod manager;
mod secure;
mod auth;
// Functions
2024-06-15 13:23:52 -05:00
fn stage_authorize(auth_profile: &mut auth::Auth) {
2024-06-14 13:32:02 -05:00
// Checking if we need to register or log in
if auth::Auth::exists() {
// Asking user for login credentials
let (username, password) = interface::int_auth();
// Verify the user
2024-06-15 13:23:52 -05:00
*auth_profile = auth::Auth::authenticate(username, password);
2024-06-14 13:32:02 -05:00
} else {
// Asking user for register credentials
let (username, password) = interface::int_reg();
2024-06-14 13:32:02 -05:00
// Creating the user
2024-06-15 13:23:52 -05:00
*auth_profile = auth::Auth::create(username, password);
}
}
fn stage_manager(auth_profile: &mut auth::Auth) {
// Loop
loop {
// What page shall we go to?
let page: String = interface::int_welcome(&auth_profile.username);
// New line
println!("\n");
// Deciding what page we are on
if page == "4" {
println!("Goodbye, {}!", auth_profile.username);
break;
} else if page == "3" {
let (pass_len, pass_num, pass_spe) = interface::int_gen();
let gen_pass: String = manager::Manager::password_generate(pass_len, pass_num, pass_spe);
println!("Your password is: {}", gen_pass);
}
2024-06-14 13:32:02 -05:00
}
2024-06-15 13:23:52 -05:00
}
// Entry-Point
fn main() {
// Authorizing User
let mut auth_profile: auth::Auth = auth::Auth{verified: false, username: String::from("ERROR")};
while !auth_profile.verified {
stage_authorize(&mut auth_profile);
// Before going to the accounts page, check if the auth failed
if !auth_profile.verified {
println!("\nPlease try again!\n");
} else {break;}
}
println!("");
2024-06-15 13:23:52 -05:00
// Passwords interface
stage_manager(&mut auth_profile);
}