Deploy again
This commit is contained in:
parent
ffe080adef
commit
787428f1a5
18 changed files with 717 additions and 223 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use reqwest::Client;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tracing::{info, warn};
|
||||
use tracing::info;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct AuthResponse {
|
||||
|
|
@ -432,29 +432,25 @@ pub async fn ensure_oauth_providers(
|
|||
// Update OAuth2 providers
|
||||
let providers = settings
|
||||
.pointer_mut("/oauth2/providers")
|
||||
.and_then(|v| v.as_array_mut());
|
||||
.and_then(|v| v.as_array_mut())
|
||||
.ok_or_else(|| anyhow::anyhow!("PocketBase settings missing oauth2.providers array — cannot configure OAuth"))?;
|
||||
|
||||
if let Some(providers) = providers {
|
||||
for provider in providers.iter_mut() {
|
||||
let name = provider
|
||||
.get("name")
|
||||
.and_then(|n| n.as_str())
|
||||
.unwrap_or("");
|
||||
|
||||
match name {
|
||||
"google" => {
|
||||
provider["clientId"] = serde_json::json!(google_client_id);
|
||||
provider["clientSecret"] = serde_json::json!(google_client_secret);
|
||||
provider["enabled"] = serde_json::json!(true);
|
||||
info!("Configured Google OAuth provider");
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
let google = match providers
|
||||
.iter()
|
||||
.position(|p| p.get("name").and_then(|n| n.as_str()) == Some("google"))
|
||||
{
|
||||
Some(idx) => &mut providers[idx],
|
||||
None => {
|
||||
info!("Google provider not found in PocketBase settings — adding it");
|
||||
providers.push(serde_json::json!({"name": "google"}));
|
||||
providers.last_mut().expect("just pushed")
|
||||
}
|
||||
} else {
|
||||
warn!("PocketBase settings missing oauth2.providers array — cannot configure OAuth");
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
google["clientId"] = serde_json::json!(google_client_id);
|
||||
google["clientSecret"] = serde_json::json!(google_client_secret);
|
||||
google["enabled"] = serde_json::json!(true);
|
||||
info!("Configured Google OAuth provider");
|
||||
|
||||
// PATCH settings back
|
||||
let patch_resp = client
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue