fix(users): add bad request for openidconnect (#9244)

This commit is contained in:
Rachit Naithani
2025-09-10 13:30:01 +05:30
committed by GitHub
parent 041656ec66
commit 09d475b423

View File

@ -76,7 +76,14 @@ pub async fn get_user_email_from_oidc_provider(
.exchange_code(oidc::AuthorizationCode::new(authorization_code.expose()))
.request_async(|req| get_oidc_reqwest_client(state, req))
.await
.change_context(UserErrors::InternalServerError)
.map_err(|e| match e {
oidc::RequestTokenError::ServerResponse(resp)
if resp.error() == &oidc_core::CoreErrorResponseType::InvalidGrant =>
{
UserErrors::SSOFailed
}
_ => UserErrors::InternalServerError,
})
.attach_printable("Failed to exchange code and fetch oidc token")?;
// Fetch id token from response