This commit is contained in:
Alois 2026-04-02 22:25:57 +02:00
commit 60a0d47df5
88 changed files with 12014 additions and 4756 deletions

18
src/auth/auth_user.rs Normal file
View file

@ -0,0 +1,18 @@
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct AuthUser {
pub id: i64,
pub username: String,
pub password_hash: String,
pub public_key: String,
}
impl AuthUser {
pub fn new(id: i64, username: String, password_hash: String, public_key: String) -> Self {
AuthUser {
id,
username,
password_hash,
public_key,
}
}
}

18
src/auth/local_auth.rs Normal file
View file

@ -0,0 +1,18 @@
use json::JsonValue;
use crate::util::file_util::load_file;
// NOT USED AT MOMENT
pub fn is_private_key_valid(user_id: &i64, 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
}

2
src/auth/mod.rs Normal file
View file

@ -0,0 +1,2 @@
pub mod auth_user;
pub mod local_auth;