diff --git a/browser/data-browser/src/components/RegisterSignIn.tsx b/browser/data-browser/src/components/RegisterSignIn.tsx index e893114cc..f54fd10a7 100644 --- a/browser/data-browser/src/components/RegisterSignIn.tsx +++ b/browser/data-browser/src/components/RegisterSignIn.tsx @@ -53,7 +53,12 @@ export function RegisterSignIn({ if (agent) { return <>{children}; } else if (!emailRegister) { - return ; + return ( + <> + + No e-mail support on this server... + + ); } return ( diff --git a/browser/react/src/useServerSupports.ts b/browser/react/src/useServerSupports.ts index 3db2b4422..15301ea7f 100644 --- a/browser/react/src/useServerSupports.ts +++ b/browser/react/src/useServerSupports.ts @@ -1,8 +1,9 @@ -import { ServerSupports, useStore } from './index.js'; +import { ServerSupports, useServerURL, useStore } from './index.js'; import { useEffect, useState } from 'react'; export function useServerSupports(): ServerSupports { const store = useStore(); + const serverURL = useServerURL(); const [supports, setSupports] = useState({ emailRegister: false, }); @@ -14,7 +15,7 @@ export function useServerSupports(): ServerSupports { } check(); - }, [store]); + }, [store, serverURL]); return supports; } diff --git a/lib/src/db.rs b/lib/src/db.rs index 29c4246bf..8ba4604e5 100644 --- a/lib/src/db.rs +++ b/lib/src/db.rs @@ -129,7 +129,7 @@ impl Db { pub fn init_temp(id: &str) -> AtomicResult { let tmp_dir_path = format!(".temp/db/{}", id); let _try_remove_existing = std::fs::remove_dir_all(&tmp_dir_path); - let store = Db::init(std::path::Path::new(&tmp_dir_path), "https://localhost")?; + let mut store = Db::init(std::path::Path::new(&tmp_dir_path), "https://localhost")?; let agent = store.create_agent(None)?; store.set_default_agent(agent); store.populate()?; @@ -233,6 +233,7 @@ impl Db { let mut endpoints = build_default_endpoints(); if self.smtp_client.is_some() { + tracing::info!("SMTP client is set, adding register endpoints"); endpoints.push(plugins::register::register_endpoint()); endpoints.push(plugins::register::confirm_email_endpoint()); } @@ -645,7 +646,7 @@ impl Storelike for Db { ) } - fn populate(&self) -> AtomicResult<()> { + fn populate(&mut self) -> AtomicResult<()> { crate::populate::populate_all(self) } diff --git a/lib/src/populate.rs b/lib/src/populate.rs index 8ef8753ec..76d18659a 100644 --- a/lib/src/populate.rs +++ b/lib/src/populate.rs @@ -286,7 +286,7 @@ pub fn populate_sidebar_items(store: &crate::Db) -> AtomicResult<()> { /// Runs all populate commands. Optionally runs index (blocking), which can be slow! #[cfg(feature = "db")] -pub fn populate_all(store: &crate::Db) -> AtomicResult<()> { +pub fn populate_all(store: &mut crate::Db) -> AtomicResult<()> { // populate_base_models should be run in init, instead of here, since it will result in infinite loops without populate_default_store(store) .map_err(|e| format!("Failed to populate default store. {}", e))?; @@ -295,5 +295,6 @@ pub fn populate_all(store: &crate::Db) -> AtomicResult<()> { populate_collections(store).map_err(|e| format!("Failed to populate collections. {}", e))?; populate_sidebar_items(store) .map_err(|e| format!("Failed to populate sidebar items. {}", e))?; + store.register_default_endpoints()?; Ok(()) } diff --git a/lib/src/storelike.rs b/lib/src/storelike.rs index 4bf07e0cb..55b3a18bf 100644 --- a/lib/src/storelike.rs +++ b/lib/src/storelike.rs @@ -372,7 +372,7 @@ pub trait Storelike: Sized { } /// Loads the default store. For DBs it also adds default Collections and Endpoints. - fn populate(&self) -> AtomicResult<()> { + fn populate(&mut self) -> AtomicResult<()> { crate::populate::populate_base_models(self)?; crate::populate::populate_default_store(self) } diff --git a/server/Cargo.toml b/server/Cargo.toml index 9800c7a95..a458abdf3 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -39,7 +39,7 @@ rustls-pemfile = "1" sanitize-filename = "0.4" serde_json = "1" simple-server-timing-header = "0.1.0" -static-files = "0.2" +static-files = "0.2.3" tantivy = "0.19" tracing = "0.1" tracing-actix-web = "0.6" diff --git a/server/src/appstate.rs b/server/src/appstate.rs index 66aa550c8..ed71f9619 100644 --- a/server/src/appstate.rs +++ b/server/src/appstate.rs @@ -29,11 +29,10 @@ pub struct AppState { /// Initializes the Store and sets the default agent. pub fn init_store(config: &Config) -> AtomicServerResult { - let mut store = atomic_lib::Db::init(&config.store_path, &config.server_url)?; + let store = atomic_lib::Db::init(&config.store_path, &config.server_url)?; tracing::info!("Setting default agent"); set_default_agent(config, &store)?; - store.register_default_endpoints()?; Ok(store) } @@ -66,11 +65,6 @@ pub async fn init(config: Config) -> AtomicServerResult { }; let should_init = !&config.store_path.exists() || config.initialize; - if should_init { - tracing::info!("Initialize: creating and populating new Database..."); - atomic_lib::populate::populate_default_store(&store) - .map_err(|e| format!("Failed to populate default store. {}", e))?; - } // Initialize search constructs tracing::info!("Starting search service"); @@ -95,7 +89,9 @@ pub async fn init(config: Config) -> AtomicServerResult { // If the user changes their server_url, the drive will not exist. // In this situation, we should re-build a new drive from scratch. if should_init { - atomic_lib::populate::populate_all(&store)?; + tracing::info!("Initialize: creating and populating new Database..."); + + atomic_lib::populate::populate_all(&mut store)?; // Building the index here is needed to perform Queries on imported resources let store_clone = store.clone(); std::thread::spawn(move || {