diff --git a/backend/src/main.rs b/backend/src/main.rs index 11995eb..dc826df 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -52,18 +52,22 @@ async fn auth_middleware( request: Request, next: Next, ) -> Result { - // Skip auth for public paths + // Skip auth for public server functions let path = request.uri().path(); - if path.starts_with("/api/server_fns/Login") // Login server fn + if path.starts_with("/api/server_fns/Login") + || path.starts_with("/api/server_fns/login") || path.starts_with("/api/server_fns/GetSetupStatus") + || path.starts_with("/api/server_fns/get_setup_status") || path.starts_with("/api/server_fns/Setup") + || path.starts_with("/api/server_fns/setup") || path.starts_with("/swagger-ui") || path.starts_with("/api-docs") - || !path.starts_with("/api/") // Allow static files (frontend) + || !path.starts_with("/api/") { return Ok(next.run(request).await); } + // Check token if let Some(token) = jar.get("auth_token") { use jsonwebtoken::{decode, Validation, DecodingKey}; @@ -221,6 +225,18 @@ async fn main() { tracing::info!("Socket: {}", args.socket); tracing::info!("Port: {}", args.port); + // Force linking of server functions from shared crate for registration on Mac + { + use shared::server_fns::auth::*; + let _ = get_setup_status; + let _ = setup; + let _ = login; + let _ = logout; + let _ = get_user; + tracing::info!("Server functions linked successfully."); + } + + // ... rest of the main function ... // Startup Health Check let socket_path = std::path::Path::new(&args.socket); diff --git a/frontend/Cargo.toml b/frontend/Cargo.toml index 9c38e0c..21224f6 100644 --- a/frontend/Cargo.toml +++ b/frontend/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" crate-type = ["cdylib", "rlib"] [dependencies] -leptos = { version = "0.8.15", features = ["csr", "msgpack"] } +leptos = { version = "0.8.15", features = ["csr", "msgpack", "nightly"] } leptos_router = { version = "0.8.11" } console_error_panic_hook = "0.1" diff --git a/shared/src/server_fns/auth.rs b/shared/src/server_fns/auth.rs index a7d7e07..014e9eb 100644 --- a/shared/src/server_fns/auth.rs +++ b/shared/src/server_fns/auth.rs @@ -20,7 +20,7 @@ pub struct SetupStatus { pub completed: bool, } -#[server(GetSetupStatus, "/api/server_fns/GetSetupStatus", input = MsgPack, output = MsgPack)] +#[server(GetSetupStatus, "/api/server_fns", input = MsgPack, output = MsgPack)] pub async fn get_setup_status() -> Result { use crate::DbContext; @@ -33,7 +33,7 @@ pub async fn get_setup_status() -> Result { }) } -#[server(Setup, "/api/server_fns/Setup", input = MsgPack, output = MsgPack)] +#[server(Setup, "/api/server_fns", input = MsgPack, output = MsgPack)] pub async fn setup(username: String, password: String) -> Result<(), ServerFnError> { use crate::DbContext; @@ -55,7 +55,7 @@ pub async fn setup(username: String, password: String) -> Result<(), ServerFnErr Ok(()) } -#[server(Login, "/api/server_fns/Login", input = MsgPack, output = MsgPack)] +#[server(Login, "/api/server_fns", input = MsgPack, output = MsgPack)] pub async fn login(username: String, password: String) -> Result { use crate::DbContext; use leptos_axum::ResponseOptions; @@ -111,7 +111,7 @@ pub async fn login(username: String, password: String) -> Result Result<(), ServerFnError> { use leptos_axum::ResponseOptions; use cookie::{Cookie, SameSite}; @@ -132,7 +132,7 @@ pub async fn logout() -> Result<(), ServerFnError> { Ok(()) } -#[server(GetUser, "/api/server_fns/GetUser", input = MsgPack, output = MsgPack)] +#[server(GetUser, "/api/server_fns", input = MsgPack, output = MsgPack)] pub async fn get_user() -> Result, ServerFnError> { use axum::http::HeaderMap; use leptos_axum::extract; diff --git a/vibetorrent.db-shm b/vibetorrent.db-shm new file mode 100644 index 0000000..acc32ee Binary files /dev/null and b/vibetorrent.db-shm differ diff --git a/vibetorrent.db-wal b/vibetorrent.db-wal new file mode 100644 index 0000000..796a6de Binary files /dev/null and b/vibetorrent.db-wal differ