From 3e9d572e2fbfaecb9510f3588fd252f1e92a5b03 Mon Sep 17 00:00:00 2001 From: Olivier D Date: Mon, 21 Jul 2025 09:36:15 +0200 Subject: [PATCH] Update crates/handlers/src/upstream_oauth2/link.rs Co-authored-by: Quentin Gliech --- crates/handlers/src/upstream_oauth2/link.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/handlers/src/upstream_oauth2/link.rs b/crates/handlers/src/upstream_oauth2/link.rs index afab80aed..7bb8a09b7 100644 --- a/crates/handlers/src/upstream_oauth2/link.rs +++ b/crates/handlers/src/upstream_oauth2/link.rs @@ -694,9 +694,12 @@ pub(crate) async fn post( .as_deref() .unwrap_or(DEFAULT_LOCALPART_TEMPLATE); - let localpart = render_attribute_template(&env, template, &context, true)?; + let Some(localpart) = render_attribute_template(&env, template, &context, true)? else { + // This should never be the case at this point + return Err(RouteError::InvalidFormAction); + }; - let maybe_user = repo.user().find_by_username(&localpart.unwrap()).await?; + let maybe_user = repo.user().find_by_username(&localpart).await?; let Some(user) = maybe_user else { // user cannot be None at this stage