Skip to content

Commit 60f7365

Browse files
committed
Human-readable error page on the upstream callback page
1 parent 58c16a2 commit 60f7365

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

crates/handlers/src/upstream_oauth2/callback.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use axum::{
1313
response::{Html, IntoResponse, Response},
1414
};
1515
use hyper::StatusCode;
16-
use mas_axum_utils::{cookies::CookieJar, record_error};
16+
use mas_axum_utils::{GenericError, InternalError, cookies::CookieJar};
1717
use mas_data_model::{UpstreamOAuthProvider, UpstreamOAuthProviderResponseMode};
1818
use mas_jose::claims::TokenHash;
1919
use mas_keystore::{Encrypter, Keystore};
@@ -153,15 +153,13 @@ impl_from_error_for_route!(super::cookie::UpstreamSessionNotFound);
153153

154154
impl IntoResponse for RouteError {
155155
fn into_response(self) -> axum::response::Response {
156-
let sentry_event_id = record_error!(self, Self::Internal(_));
157-
let response = match self {
158-
Self::ProviderNotFound => (StatusCode::NOT_FOUND, "Provider not found").into_response(),
159-
Self::SessionNotFound => (StatusCode::NOT_FOUND, "Session not found").into_response(),
160-
Self::Internal(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
161-
e => (StatusCode::BAD_REQUEST, e.to_string()).into_response(),
162-
};
163-
164-
(sentry_event_id, response).into_response()
156+
match self {
157+
Self::Internal(e) => InternalError::new(e).into_response(),
158+
e @ (Self::ProviderNotFound | Self::SessionNotFound) => {
159+
GenericError::new(StatusCode::NOT_FOUND, e).into_response()
160+
}
161+
e => GenericError::new(StatusCode::BAD_REQUEST, e).into_response(),
162+
}
165163
}
166164
}
167165

0 commit comments

Comments
 (0)