Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix: disable sync if keys aren't provided (#3304)
Nathan.foooabb6eff23dbd
diff --git a/frontend/rust-lib/flowy-core/src/integrate/server.rs b/frontend/rust-lib/flowy-core/src/integrate/server.rsindex d3a57db22f..75e8fefa34 100644--- a/frontend/rust-lib/flowy-core/src/integrate/server.rs+++ b/frontend/rust-lib/flowy-core/src/integrate/server.rs@@ -130,7 +130,15 @@ impl AppFlowyServerProvider {Ok::<Arc<dyn AppFlowyServer>, FlowyError>(server)},ServerProviderType::Supabase => {- let config = SupabaseConfiguration::from_env()?;+ let config = match SupabaseConfiguration::from_env() {+ Ok(config) => config,+ Err(e) => {+ *self.enable_sync.write() = false;+ return Err(e);+ },+ };++ tracing::trace!("🔑Supabase config: {:?}", config);let encryption = Arc::downgrade(&*self.encryption.read());Ok::<Arc<dyn AppFlowyServer>, FlowyError>(Arc::new(SupabaseServer::new(config,diff --git a/frontend/rust-lib/flowy-server-config/src/supabase_config.rs b/frontend/rust-lib/flowy-server-config/src/supabase_config.rsindex 0e7c37416d..3e11eb3e7a 100644--- a/frontend/rust-lib/flowy-server-config/src/supabase_config.rs+++ b/frontend/rust-lib/flowy-server-config/src/supabase_config.rs@@ -23,12 +23,20 @@ pub struct SupabaseConfiguration {impl SupabaseConfiguration {pub fn from_env() -> Result<Self, FlowyError> {- Ok(Self {- url: std::env::var(SUPABASE_URL)- .map_err(|_| FlowyError::new(ErrorCode::InvalidAuthConfig, "Missing SUPABASE_URL"))?,- anon_key: std::env::var(SUPABASE_ANON_KEY)- .map_err(|_| FlowyError::new(ErrorCode::InvalidAuthConfig, "Missing SUPABASE_ANON_KEY"))?,- })+ let url = std::env::var(SUPABASE_URL)+ .map_err(|_| FlowyError::new(ErrorCode::InvalidAuthConfig, "Missing SUPABASE_URL"))?;++ let anon_key = std::env::var(SUPABASE_ANON_KEY)+ .map_err(|_| FlowyError::new(ErrorCode::InvalidAuthConfig, "Missing SUPABASE_ANON_KEY"))?;++ if url.is_empty() || anon_key.is_empty() {+ return Err(FlowyError::new(+ ErrorCode::InvalidAuthConfig,+ "Missing SUPABASE_URL or SUPABASE_ANON_KEY",+ ));+ }++ Ok(Self { url, anon_key })}/// Write the configuration to the environment variables.