Client:PortalSettings:OAuth2: enable allowed origins for edit, fix error translation

This commit is contained in:
Timofey Boyko 2023-12-08 11:55:02 +03:00
parent 86ed0acd04
commit 80ebe7c16a
6 changed files with 28 additions and 11 deletions

View File

@ -20,7 +20,7 @@
"EditApp": "Edit application",
"EnterDescription": "Enter description",
"ErrorName": "Minimal name length:",
"ErrorWrongURL": "Wrong URL",
"ErrorWrongURL": "URL not valid, example",
"EnterURL": "Enter URL",
"IconDescription": "JPG, PNG or SVG, 32x32",
"ID": "ID",

View File

@ -153,7 +153,7 @@ const BasicBlock = ({
name={"website_url"}
placeholder={t("EnterURL")}
value={websiteUrlValue}
error={`${t("ErrorWrongURL")}`}
error={`${t("ErrorWrongURL")}: ${window.location.origin}`}
onChange={onChange}
disabled={isEdit}
isRequired

View File

@ -74,7 +74,7 @@ const MultiInputGroup = ({
value={value}
placeholder={placeholder}
onChange={onChange}
error={t("ErrorWrongURL")}
error={`${t("ErrorWrongURL")}: ${window.location.origin}`}
isRequired
isError={isError}
>

View File

@ -46,7 +46,6 @@ const OAuthBlock = ({
onAdd={changeValue}
currentValue={allowedOriginsValue}
helpButtonText={t("AllowedOriginsHelpButton")}
isDisabled={isEdit}
/>
</StyledInputBlock>
</StyledBlock>

View File

@ -43,7 +43,7 @@ const SupportBlock = ({
name={"policy_url"}
placeholder={t("EnterURL")}
value={policyUrlValue}
error={t("ErrorWrongURL")}
error={`${t("ErrorWrongURL")}: ${window.location.origin}`}
onChange={onChange}
helpButtonText={t("PrivacyPolicyURLHelpButton")}
disabled={isEdit}
@ -56,7 +56,7 @@ const SupportBlock = ({
name={"terms_url"}
placeholder={t("EnterURL")}
value={termsUrlValue}
error={t("ErrorWrongURL")}
error={`${t("ErrorWrongURL")}: ${window.location.origin}`}
onChange={onChange}
helpButtonText={t("TermsOfServiceURLHelpButton")}
disabled={isEdit}

View File

@ -156,10 +156,16 @@ const ClientForm = ({
website_url: fetchedClient?.websiteUrl || client?.websiteUrl || "",
description: fetchedClient?.description || client?.description || "",
redirect_uris:
fetchedClient?.redirectUris || client?.redirectUris || [],
allowed_origins:
fetchedClient?.allowedOrigins || client?.allowedOrigins || [],
redirect_uris: fetchedClient?.redirectUris
? [...fetchedClient?.redirectUris]
: client?.redirectUris
? [...client?.redirectUris]
: [],
allowed_origins: fetchedClient?.allowedOrigins
? [...fetchedClient.allowedOrigins]
: client?.allowedOrigins
? [...client.allowedOrigins]
: [],
logout_redirect_uri:
fetchedClient?.logoutRedirectUri || client?.logoutRedirectUri || "",
@ -173,7 +179,11 @@ const ClientForm = ({
client?.authenticationMethods.includes(AuthenticationMethod.none) ||
false,
scopes: fetchedClient?.scopes || client?.scopes || [],
scopes: fetchedClient?.scopes
? [...fetchedClient.scopes]
: client?.scopes
? [...client.scopes]
: [],
});
setClientId(fetchedClient?.clientId || client?.clientId || "");
@ -257,13 +267,21 @@ const ClientForm = ({
}
}
console.log(
isValid,
form?.allowed_origins?.length,
initialClient?.allowedOrigins?.length
);
return (
isValid &&
form.name &&
form.logo &&
form.allowed_origins.length > 0 &&
(form.name !== initialClient.name ||
form.logo !== initialClient.logo ||
form.description !== initialClient.description ||
form.allowed_origins.length !== initialClient.allowedOrigins.length ||
form.allow_pkce !==
initialClient.authenticationMethods.includes(
AuthenticationMethod.none