Skip to content

Commit

Permalink
Add constants to ServerConfigurationsConstants
Browse files Browse the repository at this point in the history
  • Loading branch information
hwupathum committed May 30, 2024
1 parent 6920578 commit d0cfb2d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
21 changes: 14 additions & 7 deletions features/admin.extensions.v1/configs/server-configuration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,20 @@ export const serverConfigurationConfig: ServerConfigurationConfig = {
ServerConfigurationsConstants.ANALYTICS_ENGINE_CONNECTOR_ID
],
connectorToggleName: {
"account-recovery": ServerConfigurationsConstants.PASSWORD_RECOVERY_NOTIFICATION_BASED_ENABLE,
"account-recovery-username": ServerConfigurationsConstants.USERNAME_RECOVERY_ENABLE,
"account.lock.handler": ServerConfigurationsConstants.ACCOUNT_LOCK_ENABLE,
"multiattribute.login.handler": ServerConfigurationsConstants.MULTI_ATTRIBUTE_LOGIN_ENABLE,
"organization-self-service": ServerConfigurationsConstants.ORGANIZATION_SELF_SERVICE_ENABLE,
"self-sign-up": ServerConfigurationsConstants.SELF_REGISTRATION_ENABLE,
"sso.login.recaptcha": ServerConfigurationsConstants.RE_CAPTCHA_ALWAYS_ENABLE
[ServerConfigurationsConstants.ACCOUNT_RECOVERY]:
ServerConfigurationsConstants.PASSWORD_RECOVERY_NOTIFICATION_BASED_ENABLE,
[ServerConfigurationsConstants.ACCOUNT_RECOVERY_BY_USERNAME]:
ServerConfigurationsConstants.USERNAME_RECOVERY_ENABLE,
[ServerConfigurationsConstants.ACCOUNT_LOCK_HANDLER]:
ServerConfigurationsConstants.ACCOUNT_LOCK_ENABLE,
[ServerConfigurationsConstants.MULTI_ATTRIBUTE_LOGIN_HANDLER]:
ServerConfigurationsConstants.MULTI_ATTRIBUTE_LOGIN_ENABLE,
[ServerConfigurationsConstants.ORGANIZATION_SELF_SERVICE]:
ServerConfigurationsConstants.ORGANIZATION_SELF_SERVICE_ENABLE,
[ServerConfigurationsConstants.SELF_SIGNUP]:
ServerConfigurationsConstants.SELF_REGISTRATION_ENABLE,
[ServerConfigurationsConstants.SSO_LOGIN_RECAPTCHA]:
ServerConfigurationsConstants.RE_CAPTCHA_AFTER_MAX_FAILED_ATTEMPTS_ENABLE
},
connectorsToHide: [
ServerConfigurationsConstants.ALTERNATIVE_LOGIN_IDENTIFIER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ export class ServerConfigurationsConstants {
public static readonly PASSWORD_RECOVERY_QUESTION_FORCED_ENABLE: string =
"Recovery.Question.Password.Forced.Enable";

/**
* Connector toggle constants.
*/
public static readonly ACCOUNT_RECOVERY: string = "account-recovery";
public static readonly ACCOUNT_RECOVERY_BY_USERNAME: string = "account-recovery-username";
public static readonly ACCOUNT_LOCK_HANDLER: string = "account.lock.handler";
public static readonly MULTI_ATTRIBUTE_LOGIN_HANDLER: string = "multiattribute.login.handler";
public static readonly ORGANIZATION_SELF_SERVICE: string = "organization-self-service";
public static readonly SELF_SIGNUP: string = "self-sign-up";
public static readonly SSO_LOGIN_RECAPTCHA: string = "sso.login.recaptcha";

/**
* Login policies - account locking API Keyword constants.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export const ConnectorEditPage: FunctionComponent<ConnectorEditPageInterface> =
const { t } = useTranslation();
const { getLink } = useDocumentation();

const ACCOUNT_RECOVERY_BY_USERNAME: string = "account-recovery-username";
const featureConfig: FeatureConfigInterface = useSelector((state: AppState) => state.config.ui.features);
const allowedScopes: string = useSelector((state: AppState) => state?.auth?.allowedScopes);

Expand Down Expand Up @@ -185,7 +184,8 @@ export const ConnectorEditPage: FunctionComponent<ConnectorEditPageInterface> =
// TODO: remove this once the ID is fixed
updateData.properties.push({
name: GovernanceConnectorUtils.decodeConnectorPropertyName(
serverConfigurationConfig.connectorToggleName[ACCOUNT_RECOVERY_BY_USERNAME]
serverConfigurationConfig.connectorToggleName[
ServerConfigurationsConstants.ACCOUNT_RECOVERY_BY_USERNAME ]
),
value: data.checked.toString()
});
Expand Down Expand Up @@ -251,7 +251,8 @@ export const ConnectorEditPage: FunctionComponent<ConnectorEditPageInterface> =
name: ServerConfigurationsConstants.PASSWORD_RECOVERY_NOTIFICATION_BASED_RE_CAPTCHA,
value: data.checked.toString()
});
if (ACCOUNT_RECOVERY_BY_USERNAME in serverConfigurationConfig.connectorToggleName) {
if (ServerConfigurationsConstants.ACCOUNT_RECOVERY_BY_USERNAME in
serverConfigurationConfig.connectorToggleName) {
updateRecoveryCaptchaData.properties.push({
name: ServerConfigurationsConstants.USERNAME_RECOVERY_RE_CAPTCHA,
value: data.checked.toString()
Expand Down Expand Up @@ -622,7 +623,8 @@ export const ConnectorEditPage: FunctionComponent<ConnectorEditPageInterface> =
) }
</li>
{
serverConfigurationConfig.connectorToggleName[ACCOUNT_RECOVERY_BY_USERNAME] ?
serverConfigurationConfig.connectorToggleName[
ServerConfigurationsConstants.ACCOUNT_RECOVERY_BY_USERNAME ] ?
(<li>
{ t(
"extensions:manage.serverConfigurations.accountSecurity." +
Expand Down

0 comments on commit d0cfb2d

Please sign in to comment.