mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: disable sync if keys aren't provided (#3304)
This commit is contained in:
parent
3b4f8e53a2
commit
abb6eff23d
@ -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,
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user