diff --git a/package.json b/package.json index 673f599..7b18741 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "has", "private": true, - "version": "0.0.7", + "version": "0.0.8", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 1471446..f1dbeeb 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1581,7 +1581,7 @@ dependencies = [ [[package]] name = "has" -version = "0.0.6" +version = "0.0.8" dependencies = [ "base64 0.22.1", "bcrypt", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index b5783d9..2fc3e1a 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "has" -version = "0.0.7" +version = "0.0.8" description = "has" authors = ["autli"] edition = "2024" diff --git a/src-tauri/src/admin.rs b/src-tauri/src/admin.rs index 048733c..9f9b836 100644 --- a/src-tauri/src/admin.rs +++ b/src-tauri/src/admin.rs @@ -85,16 +85,17 @@ pub async fn init_admin_security_table(client: &tokio_postgres::Client) -> Resul VALUES (1, false, false) ON CONFLICT (id) DO NOTHING; "; - client - .batch_execute(sql) - .await - .map_err(|e| format!("Ошибка создания таблицы безопасности: {}", e)) + // If has_app lacks DDL permissions on public schema, do not fail admin updates + if let Err(e) = client.batch_execute(sql).await { + eprintln!("[admin] admin_security_config table creation skipped: {}", e); + } + Ok(()) } pub async fn get_admin_security_info(admin_email: &str) -> Result { let config = get_db_config(); let client = connect_to_db(&config).await?; - init_admin_security_table(&client).await?; + let _ = init_admin_security_table(&client).await; let clean_email = admin_email.trim().to_lowercase(); let user_row = client @@ -119,17 +120,18 @@ pub async fn get_admin_security_info(admin_email: &str) -> Result = cfg_row.get(1); - let ip_binding_enabled: bool = cfg_row.get(2); - let trusted_ip: Option = cfg_row.get(3); + let (device_binding_enabled, trusted_device_name, ip_binding_enabled, trusted_ip): (bool, Option, bool, Option) = match cfg_row { + Some(row) => (row.get(0), row.get(1), row.get(2), row.get(3)), + None => (false, None, false, None), + }; let current_device = get_current_device_name(); let current_ip = get_current_local_ip(); @@ -310,3 +312,27 @@ pub async fn admin_delete_user( Ok("Пользователь успешно удален".to_string()) } + +#[cfg(test)] +mod tests { + use super::*; + + #[tokio::test] + async fn test_init_admin_security() { + let config = get_db_config(); + if let Ok(client) = connect_to_db(&config).await { + let res = init_admin_security_table(&client).await; + assert!(res.is_ok()); + } + } + + #[tokio::test] + async fn test_get_admin_security_info() { + let config = get_db_config(); + if let Ok(_) = connect_to_db(&config).await { + let res = get_admin_security_info("dimatyilickiy0511@gmail.com").await; + println!("get_admin_security_info result: {:?}", res); + assert!(res.is_ok()); + } + } +} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 935e20b..5074f2a 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "has", - "version": "0.0.7", + "version": "0.0.8", "identifier": "com.has.tauri-app", "build": { "beforeDevCommand": "npm run dev",