Human-readable error page on the upstream authorization page

This commit is contained in:
Quentin Gliech
2025-07-23 19:36:17 +02:00
parent d356ae5732
commit 089de9ef8f

View File

@@ -9,7 +9,7 @@ use axum::{
response::{IntoResponse, Redirect},
};
use hyper::StatusCode;
use mas_axum_utils::{cookies::CookieJar, record_error};
use mas_axum_utils::{GenericError, InternalError, cookies::CookieJar};
use mas_data_model::UpstreamOAuthProvider;
use mas_oidc_client::requests::authorization_code::AuthorizationRequestData;
use mas_router::{PostAuthAction, UrlBuilder};
@@ -41,13 +41,12 @@ impl_from_error_for_route!(mas_storage::RepositoryError);
impl IntoResponse for RouteError {
fn into_response(self) -> axum::response::Response {
let sentry_event_id = record_error!(self, Self::Internal(_));
let response = match self {
Self::ProviderNotFound => (StatusCode::NOT_FOUND, "Provider not found").into_response(),
Self::Internal(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
};
(sentry_event_id, response).into_response()
match self {
e @ Self::ProviderNotFound => {
GenericError::new(StatusCode::NOT_FOUND, e).into_response()
}
Self::Internal(e) => InternalError::new(e).into_response(),
}
}
}