mirror of
https://github.com/keycloak/keycloak.git
synced 2025-12-21 14:30:05 -06:00
Translate the validation error returned from the backend
Closes #42182 Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
This commit is contained in:
committed by
GitHub
parent
0897560513
commit
6fce9c89e4
@@ -1,7 +1,12 @@
|
||||
import RequiredActionConfigInfoRepresentation from "@keycloak/keycloak-admin-client/lib/defs/requiredActionConfigInfoRepresentation";
|
||||
import RequiredActionConfigRepresentation from "@keycloak/keycloak-admin-client/lib/defs/requiredActionConfigRepresentation";
|
||||
import type RequiredActionProviderRepresentation from "@keycloak/keycloak-admin-client/lib/defs/requiredActionProviderRepresentation";
|
||||
import { useAlerts, useFetch } from "@keycloak/keycloak-ui-shared";
|
||||
import {
|
||||
isUserProfileError,
|
||||
setUserProfileServerError,
|
||||
useAlerts,
|
||||
useFetch,
|
||||
} from "@keycloak/keycloak-ui-shared";
|
||||
import {
|
||||
ActionGroup,
|
||||
AlertVariant,
|
||||
@@ -90,7 +95,19 @@ export const RequiredActionConfigModal = ({
|
||||
addAlert(t("configSaveSuccess"), AlertVariant.success);
|
||||
onClose();
|
||||
} catch (error) {
|
||||
addError("configSaveError", error);
|
||||
if (isUserProfileError(error)) {
|
||||
setUserProfileServerError(
|
||||
error,
|
||||
(name: string | number, error: unknown) => {
|
||||
// TODO: Does not set set the error message to the field, yet.
|
||||
// Still, this will do all front end replacement and translation of keys.
|
||||
addError("configSaveError", (error as any).message);
|
||||
},
|
||||
t,
|
||||
);
|
||||
} else {
|
||||
addError("configSaveError", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user