bypass emergency-password feature when ldap enabled

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-04-24 13:01:02 +00:00
parent 448ac63a21
commit c11c5e61c9

View File

@@ -7,7 +7,7 @@ use ruma::{
},
push::Ruleset,
};
use tuwunel_core::{Result, error, warn};
use tuwunel_core::{Result, debug_warn, error, warn};
use crate::{Dep, account_data, config, globals, users};
@@ -37,16 +37,30 @@ impl crate::Service for Service {
}
async fn worker(self: Arc<Self>) -> Result {
if self
.services
.config
.emergency_password
.as_ref()
.is_none_or(String::is_empty)
{
return Ok(());
}
if self.services.globals.is_read_only() {
debug_warn!("emergency password feature ignored in read_only mode.");
return Ok(());
}
if self.services.config.ldap.enable {
warn!("emergency password feature not available with LDAP enabled.");
return Ok(());
}
self.set_emergency_access()
.await
.inspect_err(|e| {
error!(
"Could not set the configured emergency password for the server user: {e}"
);
error!("Failed to set the emergency password for the server user: {e}");
})
}