19 lines
506 B
Rust
19 lines
506 B
Rust
use json::JsonValue;
|
|
use uuid::Uuid;
|
|
|
|
use crate::util::file_util::load_file;
|
|
|
|
pub fn is_private_key_valid(user_id: &Uuid, key_hash: &str) -> bool {
|
|
let file_contents = load_file("", "users.json");
|
|
|
|
let users = json::parse(&file_contents).unwrap();
|
|
if let JsonValue::Array(users_array) = users {
|
|
for user in users_array {
|
|
if user["uuid"] == user_id.to_string() && user["private_key_hash"] == key_hash {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
false
|
|
}
|