Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(applications): simplify conditional auth looping constructs error message #2554

Merged
merged 2 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import { AlertLevels, SBACInterface, TestableComponentInterface } from "@wso2is/core/models";
import { addAlert } from "@wso2is/core/store";
import { Field, Forms } from "@wso2is/forms";
import { Heading, Hint, LinkButton, PrimaryButton } from "@wso2is/react-components";
import { Code, Heading, Hint, LinkButton, PrimaryButton } from "@wso2is/react-components";
import kebabCase from "lodash-es/kebabCase";
import React, { FunctionComponent, ReactElement, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { Trans, useTranslation } from "react-i18next";
import { useDispatch, useSelector } from "react-redux";
import { Divider, Grid, Icon } from "semantic-ui-react";
import { ScriptBasedFlow } from "./script-based-flow";
Expand Down Expand Up @@ -250,6 +250,30 @@ export const SignInMethodCustomization: FunctionComponent<SignInMethodCustomizat
onUpdate(appId);
})
.catch((error) => {

const DISALLOWED_PROGRAMMING_CONSTRUCTS = "APP-60001";
if (error.response && error.response.data?.code === DISALLOWED_PROGRAMMING_CONSTRUCTS) {
dispatch(addAlert({
description: (
<p>
<Trans
i18nKey={
"console:develop.features.applications.notifications" +
".conditionalScriptLoopingError.description"
}>
Looping constructs such as <Code>for</Code>, <Code>while</Code> and,
<Code>forEach</Code> are not allowed in the conditional authentication
script.
</Trans>
</p>
),
level: AlertLevels.ERROR,
message: t("console:develop.features.applications.notifications" +
".conditionalScriptLoopingError.message")
}));
return;
}

if (error.response && error.response.data && error.response.data.description) {
dispatch(addAlert({
description: error.response.data.description,
Expand Down
1 change: 1 addition & 0 deletions modules/i18n/src/models/namespaces/console-ns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@ export interface ConsoleNS {
updateProtocol: Notification;
fetchOIDCServiceEndpoints: Notification;
secondFactorAuthenticatorToFirstStep: Notification;
conditionalScriptLoopingError: NotificationItem;
};
popups: {
appStatus: {
Expand Down
6 changes: 6 additions & 0 deletions modules/i18n/src/translations/en-US/portals/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2603,6 +2603,12 @@ export const console: ConsoleNS = {
description: "Successfully added new protocol configurations.",
message: "Update successful"
}
},
conditionalScriptLoopingError: {
description: "Looping constructs such as <1>for</1>, <3>while</3>, and" +
" <5>forEach</5> are not allowed in the conditional authentication" +
" script.",
message: "Failed to update the script"
}
},
placeholders: {
Expand Down
5 changes: 5 additions & 0 deletions modules/i18n/src/translations/fr-FR/portals/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2619,6 +2619,11 @@ export const console: ConsoleNS = {
description: "Ajout réussi de nouvelles configurations de protocole.",
message: "Mise à jour réussie"
}
},
conditionalScriptLoopingError: {
description: "Les constructions en boucle telles que <1>for</1>, <3>while</3> et " +
"<5>forEach</5> ne sont pas autorisées dans le script d'authentification conditionnelle.",
message: "Échec de la mise à jour du script"
}
},
placeholders: {
Expand Down
5 changes: 5 additions & 0 deletions modules/i18n/src/translations/si-LK/portals/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2563,6 +2563,11 @@ export const console: ConsoleNS = {
description: "නව ප්‍රොටොකෝල් වින්‍යාසයන් සාර්ථකව එක් කරන ලදි.",
message: "යාවත්කාලීන කිරීම සාර්ථකයි"
}
},
conditionalScriptLoopingError: {
description: "කොන්දේසි සහිත සත්‍යාපන පිටපත තුළ <1>for</1>, <3>while</3>, සහ <5>forEach</5>" +
" වැනි ලූප් ඉදි කිරීම් වලට ඉඩ නොදේ.",
message: "පිටපත යාවත්කාලීන කිරීමට අසමත් විය"
}
},
placeholders: {
Expand Down