Fix Chirpstack overwriting user updates by OIDC user provisioning callback (#343)

Co-authored-by: Orne Brocaar <info@brocaar.com>
This commit is contained in:
Liu Woon Yung 2024-01-11 20:28:49 +08:00 committed by GitHub
parent e379e8738c
commit f248379259
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,13 +56,16 @@ impl Internal {
external_id: Some(external_id.to_string()), external_id: Some(external_id.to_string()),
..Default::default() ..Default::default()
}; };
let u = user::create(u).await?; let mut u = user::create(u).await?;
if let Err(e) = self.provision_user(&u.id, user_info).await { if let Err(e) = self.provision_user(&u.id, user_info).await {
error!(error = %e, "Provisioning user failed"); error!(error = %e, "Provisioning user failed");
user::delete(&u.id).await?; user::delete(&u.id).await?;
return Err(e); return Err(e);
} }
// fetch user again because the provisioning callback url may have updated the user.
u = user::get(&u.id).await?;
Ok(u) Ok(u)
} }