63 lines
No EOL
1.8 KiB
Rust
63 lines
No EOL
1.8 KiB
Rust
// Libraries
|
|
mod interface;
|
|
mod resource;
|
|
mod manager;
|
|
mod secure;
|
|
mod auth;
|
|
|
|
// Functions
|
|
fn stage_authorize(auth_profile: &mut auth::Auth) {
|
|
// 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
|
|
*auth_profile = auth::Auth::authenticate(username, password);
|
|
} else {
|
|
// Asking user for register credentials
|
|
let (username, password) = interface::int_reg();
|
|
|
|
// Creating the user
|
|
*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);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 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!("");
|
|
|
|
// Passwords interface
|
|
stage_manager(&mut auth_profile);
|
|
} |