Skip to content

Commit

Permalink
feat(all): allow user/pass in args and begin frontend stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
SpikeHD committed Sep 24, 2023
1 parent ee9f01c commit 7d9fc5a
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 2,804 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules/

frontend/dist
backend/target
backend/target

.DS_Store
42 changes: 29 additions & 13 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,40 @@ struct Args {
cpu_history_max: String,

/// Rate (in seconds) at which to update the resource monitor
#[arg(short, long, default_value = "5")]
#[arg(short = 'r', long, default_value = "5")]
update_rate: u64,
}

fn main() {
let args = Args::parse();
/// Username to use for authentication
#[arg(short, long)]
username: Option<String>,

// Prompt for username
print!("Username to use while authenticating: ");
std::io::stdout().flush().unwrap();
/// Password to use for authentication. Not reccommended, use the prompt instead
#[arg(short = 'k', long)]
password: Option<String>,
}

fn main() {
let mut args = Args::parse();
let mut username = String::new();
std::io::stdin().read_line(&mut username).unwrap();

// Prompt for password
print!("Password to use while authenticating: ");
std::io::stdout().flush().unwrap();
let pwd = sha2::Sha256::digest(read_password().unwrap().as_bytes()).to_vec();
let pwd;

if args.username.is_none() || args.password.is_none() {
// Prompt for username
print!("Username to use while authenticating: ");
std::io::stdout().flush().unwrap();
std::io::stdin().read_line(&mut username).unwrap();

// Prompt for password
print!("Password to use while authenticating: ");
std::io::stdout().flush().unwrap();
pwd = sha2::Sha256::digest(read_password().unwrap().as_bytes()).to_vec();
} else {
username = args.username.unwrap();
pwd = sha2::Sha256::digest(args.password.unwrap().as_bytes()).to_vec();

// Remove the password from memory
args.password = None;
}

// Create a new stat with the username and hashed password
let state = State::new(username.trim().to_string(), pwd);
Expand Down
Binary file added frontend/bun.lockb
Binary file not shown.
45 changes: 23 additions & 22 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
{
"name": "procchi-frontend",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"preact": "^10.13.1",
"preact-iso": "^2.3.1",
"preact-render-to-string": "^6.2.1"
},
"devDependencies": {
"@preact/preset-vite": "^2.5.0",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"eslint": "^8.50.0",
"eslint-config-preact": "^1.3.0",
"typescript": "^5.2.2",
"vite": "^4.3.2"
}
"name": "procchi-frontend",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"preact": "^10.13.1",
"preact-iso": "^2.3.1",
"preact-render-to-string": "^6.2.1",
"react-charts": "^2.0.0-beta.7"
},
"devDependencies": {
"@preact/preset-vite": "^2.5.0",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"eslint": "^8.50.0",
"eslint-config-preact": "^1.3.0",
"typescript": "^5.2.2",
"vite": "^4.3.2"
}
}
Loading

0 comments on commit 7d9fc5a

Please sign in to comment.