Skip to content

Commit

Permalink
Additional logging during auth code
Browse files Browse the repository at this point in the history
  • Loading branch information
augustuswm committed Nov 20, 2024
1 parent 032cc12 commit 5e3c153
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions v-api/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ where
Ok((user, user_provider))
}
1 => {
tracing::info!("Found an existing user. Ensuring mapped permissions and groups.");
tracing::info!("Found an existing user provider. Ensuring mapped permissions and groups for user.");

// This branch ensures that there is a 0th indexed item
let mut provider = api_user_providers.into_iter().nth(0).unwrap();
Expand All @@ -428,31 +428,39 @@ where

tracing::info!(?provider.id, "Updating provider for user");

self.user
let provider = self
.user
.update_api_user_provider(caller, provider.clone().into())
.await
.map_err(|err| err.into())
.to_resource_result()?;

tracing::info!(?provider.id, ?provider.user_id, "Updating found user permissions and groups");

// Update the found user to ensure it has at least the mapped permissions and groups
let user = self
.user
.get_api_user(caller, &provider.user_id)
.await
.map_err(|err| ApiError::from(err))
.to_resource_result()?;

tracing::info!(?user.user.id, "Updating found user permissions and groups");

let mut update: NewApiUser<T> = user.user.into();
update.permissions.append(&mut mapped_permissions);
update.groups.append(&mut mapped_groups);

Ok((
self.user
.update_api_user(caller, update)
.await
.map_err(|err| ApiError::from(err))
.to_resource_result()?,
provider,
))
let updated_user = self
.user
.update_api_user(caller, update)
.await
.map_err(|err| ApiError::from(err))
.to_resource_result()?;

tracing::info!(?updated_user.user.id, "Updated user permissions and groups");

Ok((updated_user, provider))
}
_ => {
// If we found more than one provider, then we have encountered an inconsistency in
Expand Down

0 comments on commit 5e3c153

Please sign in to comment.