diff --git a/js/apps/account-ui/src/index.ts b/js/apps/account-ui/src/index.ts index 5d57ce5aee..adee82d589 100644 --- a/js/apps/account-ui/src/index.ts +++ b/js/apps/account-ui/src/index.ts @@ -1,5 +1,4 @@ export { PersonalInfo } from "./personal-info/PersonalInfo"; -export { ErrorPage } from "./root/ErrorPage"; export { Header } from "./root/Header"; export { PageNav } from "./root/PageNav"; export { DeviceActivity } from "./account-security/DeviceActivity"; diff --git a/js/apps/account-ui/src/root/ErrorPage.tsx b/js/apps/account-ui/src/root/ErrorPage.tsx deleted file mode 100644 index 97ee600e4a..0000000000 --- a/js/apps/account-ui/src/root/ErrorPage.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import { - Button, - Modal, - ModalVariant, - Page, - Text, - TextContent, - TextVariants, -} from "@patternfly/react-core"; -import { useTranslation } from "react-i18next"; -import { isRouteErrorResponse, useRouteError } from "react-router-dom"; - -type ErrorPageProps = { - error?: unknown; -}; - -export const ErrorPage = (props: ErrorPageProps) => { - const { t } = useTranslation(); - const error = useRouteError() ?? props.error; - const errorMessage = getErrorMessage(error); - - function onRetry() { - location.href = location.origin + location.pathname; - } - - return ( - - - {t("tryAgain")} - , - ]} - > - - {t("somethingWentWrongDescription")} - {errorMessage && ( - {errorMessage} - )} - - - - ); -}; - -function getErrorMessage(error: unknown): string | null { - if (typeof error === "string") { - return error; - } - - if (isRouteErrorResponse(error)) { - return error.statusText; - } - - if (error instanceof Error) { - return error.message; - } - - return null; -} diff --git a/js/apps/account-ui/src/routes.tsx b/js/apps/account-ui/src/routes.tsx index 3e549d6310..2b9fcb55c1 100644 --- a/js/apps/account-ui/src/routes.tsx +++ b/js/apps/account-ui/src/routes.tsx @@ -1,10 +1,9 @@ import { lazy } from "react"; import type { IndexRouteObject, RouteObject } from "react-router-dom"; - import { environment } from "./environment"; import { Organizations } from "./organizations/Organizations"; -import { ErrorPage } from "./root/ErrorPage"; import { Root } from "./root/Root"; +import { ErrorPage } from "@keycloak/keycloak-ui-shared"; const DeviceActivity = lazy(() => import("./account-security/DeviceActivity")); const LinkedAccounts = lazy(() => import("./account-security/LinkedAccounts")); diff --git a/js/libs/ui-shared/src/context/ErrorPage.tsx b/js/libs/ui-shared/src/context/ErrorPage.tsx index 6d66acedcd..af0babd843 100644 --- a/js/libs/ui-shared/src/context/ErrorPage.tsx +++ b/js/libs/ui-shared/src/context/ErrorPage.tsx @@ -8,6 +8,7 @@ import { TextVariants, } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; +import { getNetworkErrorDescription } from "../utils/errors"; type ErrorPageProps = { error?: unknown; @@ -16,7 +17,10 @@ type ErrorPageProps = { export const ErrorPage = (props: ErrorPageProps) => { const { t } = useTranslation(); const error = props.error; - const errorMessage = getErrorMessage(error); + const errorMessage = + getErrorMessage(error) || + getNetworkErrorDescription(error)?.replace(/\+/g, " "); + console.error(error); function onRetry() { location.href = location.origin + location.pathname; diff --git a/services/src/main/java/org/keycloak/protocol/oidc/OIDCLoginProtocol.java b/services/src/main/java/org/keycloak/protocol/oidc/OIDCLoginProtocol.java index 0bcae1ef42..7e6d26e93c 100755 --- a/services/src/main/java/org/keycloak/protocol/oidc/OIDCLoginProtocol.java +++ b/services/src/main/java/org/keycloak/protocol/oidc/OIDCLoginProtocol.java @@ -420,10 +420,10 @@ public class OIDCLoginProtocol implements LoginProtocol { case CANCELLED_AIA_SILENT: return new OAuth2ErrorRepresentation(null, null); case CANCELLED_AIA: - return new OAuth2ErrorRepresentation(OAuthErrorException.ACCESS_DENIED, "User cancelled aplication-initiated action."); + return new OAuth2ErrorRepresentation(OAuthErrorException.ACCESS_DENIED, "User cancelled application-initiated action."); case CANCELLED_BY_USER: case CONSENT_DENIED: - return new OAuth2ErrorRepresentation(OAuthErrorException.ACCESS_DENIED, null); + return new OAuth2ErrorRepresentation(OAuthErrorException.ACCESS_DENIED, "User denied consent"); case PASSIVE_INTERACTION_REQUIRED: return new OAuth2ErrorRepresentation(OAuthErrorException.INTERACTION_REQUIRED, null); case PASSIVE_LOGIN_REQUIRED: