Skip to content

Commit 9b99057

Browse files
committed
Human-readable error page on the consent page
1 parent 0629915 commit 9b99057

File tree

1 file changed

+10
-8
lines changed
  • crates/handlers/src/oauth2/authorization

1 file changed

+10
-8
lines changed

crates/handlers/src/oauth2/authorization/consent.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ use axum::{
1111
use axum_extra::TypedHeader;
1212
use hyper::StatusCode;
1313
use mas_axum_utils::{
14+
GenericError, InternalError,
1415
cookies::CookieJar,
1516
csrf::{CsrfExt, ProtectedForm},
16-
record_error,
1717
};
1818
use mas_data_model::AuthorizationGrantStage;
1919
use mas_keystore::Keystore;
@@ -64,13 +64,15 @@ impl_from_error_for_route!(super::callback::CallbackDestinationError);
6464

6565
impl IntoResponse for RouteError {
6666
fn into_response(self) -> axum::response::Response {
67-
let sentry_event_id = record_error!(self, Self::Internal(_) | Self::NoSuchClient(_));
68-
(
69-
StatusCode::INTERNAL_SERVER_ERROR,
70-
sentry_event_id,
71-
self.to_string(),
72-
)
73-
.into_response()
67+
match self {
68+
Self::Internal(e) => InternalError::new(e).into_response(),
69+
e @ Self::NoSuchClient(_) => InternalError::new(Box::new(e)).into_response(),
70+
e @ Self::GrantNotFound => GenericError::new(StatusCode::NOT_FOUND, e).into_response(),
71+
e @ Self::GrantNotPending(_) => {
72+
GenericError::new(StatusCode::CONFLICT, e).into_response()
73+
}
74+
e @ Self::Csrf(_) => GenericError::new(StatusCode::BAD_REQUEST, e).into_response(),
75+
}
7476
}
7577
}
7678

0 commit comments

Comments
 (0)