2021-04-30 19:08:12 +00:00
|
|
|
import React from "react";
|
2021-04-19 11:41:07 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2021-04-30 19:08:12 +00:00
|
|
|
import { FormGroup, PageSection, Switch } from "@patternfly/react-core";
|
2021-04-19 11:41:07 +00:00
|
|
|
import { FormAccess } from "../components/form-access/FormAccess";
|
|
|
|
import { HelpItem } from "../components/help-enabler/HelpItem";
|
|
|
|
import { FormPanel } from "../components/scroll-form/FormPanel";
|
2021-05-04 17:58:18 +00:00
|
|
|
import type RealmRepresentation from "keycloak-admin/lib/defs/realmRepresentation";
|
2021-04-19 11:41:07 +00:00
|
|
|
|
2021-04-30 19:08:12 +00:00
|
|
|
type RealmSettingsLoginTabProps = {
|
|
|
|
save: (realm: RealmRepresentation) => void;
|
|
|
|
realm: RealmRepresentation;
|
|
|
|
};
|
2021-04-19 11:41:07 +00:00
|
|
|
|
2021-04-30 19:08:12 +00:00
|
|
|
export const RealmSettingsLoginTab = ({
|
|
|
|
save,
|
|
|
|
realm,
|
|
|
|
}: RealmSettingsLoginTabProps) => {
|
|
|
|
const { t } = useTranslation("realm-settings");
|
2021-04-19 11:41:07 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<PageSection variant="light">
|
2021-05-25 12:03:20 +00:00
|
|
|
<FormPanel
|
|
|
|
className="kc-login-screen"
|
|
|
|
title="Login screen customization"
|
|
|
|
>
|
2021-05-03 20:00:12 +00:00
|
|
|
<FormAccess isHorizontal role="manage-realm">
|
|
|
|
<FormGroup
|
|
|
|
label={t("userRegistration")}
|
|
|
|
fieldId="kc-user-reg"
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={t("userRegistrationHelpText")}
|
|
|
|
forLabel={t("userRegistration")}
|
2021-07-12 14:09:14 +00:00
|
|
|
forID={t(`common:helpLabel`, { label: t("userRegistration") })}
|
2021-04-19 11:41:07 +00:00
|
|
|
/>
|
2021-05-03 20:00:12 +00:00
|
|
|
}
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
|
|
|
<Switch
|
2021-07-12 14:09:14 +00:00
|
|
|
id="kc-user-reg-switch"
|
2021-05-03 20:00:12 +00:00
|
|
|
data-testid="user-reg-switch"
|
|
|
|
name="registrationAllowed"
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
isChecked={realm?.registrationAllowed}
|
|
|
|
onChange={(value) => {
|
|
|
|
save({ ...realm, registrationAllowed: value });
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("forgotPassword")}
|
|
|
|
fieldId="kc-forgot-pw"
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={t("forgotPasswordHelpText")}
|
|
|
|
forLabel={t("forgotPassword")}
|
2021-07-12 14:09:14 +00:00
|
|
|
forID={t(`common:helpLabel`, { label: t("forgotPassword") })}
|
2021-04-19 11:41:07 +00:00
|
|
|
/>
|
2021-05-03 20:00:12 +00:00
|
|
|
}
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
|
|
|
<Switch
|
2021-07-12 14:09:14 +00:00
|
|
|
id="kc-forgot-pw-switch"
|
2021-05-03 20:00:12 +00:00
|
|
|
data-testid="forgot-pw-switch"
|
|
|
|
name="resetPasswordAllowed"
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
isChecked={realm?.resetPasswordAllowed}
|
|
|
|
onChange={(value) => {
|
|
|
|
save({ ...realm, resetPasswordAllowed: value });
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("rememberMe")}
|
|
|
|
fieldId="kc-remember-me"
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={t("rememberMeHelpText")}
|
|
|
|
forLabel={t("rememberMe")}
|
2021-07-12 14:09:14 +00:00
|
|
|
forID={t(`common:helpLabel`, { label: t("rememberMe") })}
|
2021-04-19 11:41:07 +00:00
|
|
|
/>
|
2021-05-03 20:00:12 +00:00
|
|
|
}
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
|
|
|
<Switch
|
2021-07-12 14:09:14 +00:00
|
|
|
id="kc-remember-me-switch"
|
2021-05-03 20:00:12 +00:00
|
|
|
data-testid="remember-me-switch"
|
|
|
|
name="rememberMe"
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
isChecked={realm?.rememberMe}
|
|
|
|
onChange={(value) => {
|
|
|
|
save({ ...realm, rememberMe: value });
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
</FormAccess>
|
2021-04-19 11:41:07 +00:00
|
|
|
</FormPanel>
|
2021-05-25 12:03:20 +00:00
|
|
|
<FormPanel className="kc-email-settings" title="Email settings">
|
2021-05-03 20:00:12 +00:00
|
|
|
<FormAccess isHorizontal role="manage-realm">
|
|
|
|
<FormGroup
|
|
|
|
label={t("emailAsUsername")}
|
|
|
|
fieldId="kc-email-as-username"
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={t("emailAsUsernameHelpText")}
|
|
|
|
forLabel={t("emailAsUsername")}
|
2021-07-12 14:09:14 +00:00
|
|
|
forID={t(`common:helpLabel`, { label: t("emailAsUsername") })}
|
2021-04-19 11:41:07 +00:00
|
|
|
/>
|
2021-05-03 20:00:12 +00:00
|
|
|
}
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
|
|
|
<Switch
|
2021-07-12 14:09:14 +00:00
|
|
|
id="kc-email-as-username-switch"
|
2021-05-03 20:00:12 +00:00
|
|
|
data-testid="email-as-username-switch"
|
|
|
|
name="registrationEmailAsUsername"
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
isChecked={realm?.registrationEmailAsUsername}
|
|
|
|
onChange={(value) => {
|
|
|
|
save({ ...realm, registrationEmailAsUsername: value });
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("loginWithEmail")}
|
|
|
|
fieldId="kc-login-with-email"
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={t("loginWithEmailHelpText")}
|
|
|
|
forLabel={t("loginWithEmail")}
|
2021-07-12 14:09:14 +00:00
|
|
|
forID={t(`common:helpLabel`, { label: t("loginWithEmail") })}
|
2021-04-19 11:41:07 +00:00
|
|
|
/>
|
2021-05-03 20:00:12 +00:00
|
|
|
}
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
|
|
|
<Switch
|
2021-07-12 14:09:14 +00:00
|
|
|
id="kc-login-with-email-switch"
|
2021-05-03 20:00:12 +00:00
|
|
|
data-testid="login-with-email-switch"
|
|
|
|
name="loginWithEmailAllowed"
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
isChecked={realm?.loginWithEmailAllowed}
|
|
|
|
onChange={(value) => {
|
|
|
|
save({ ...realm, loginWithEmailAllowed: value });
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("duplicateEmails")}
|
|
|
|
fieldId="kc-duplicate-emails"
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={t("duplicateEmailsHelpText")}
|
|
|
|
forLabel={t("duplicateEmails")}
|
2021-07-12 14:09:14 +00:00
|
|
|
forID={t(`common:helpLabel`, { label: t("duplicateEmails") })}
|
2021-04-19 11:41:07 +00:00
|
|
|
/>
|
2021-05-03 20:00:12 +00:00
|
|
|
}
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
|
|
|
<Switch
|
2021-07-12 14:09:14 +00:00
|
|
|
id="kc-duplicate-emails-switch"
|
2021-05-03 20:00:12 +00:00
|
|
|
data-testid="duplicate-emails-switch"
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
name="duplicateEmailsAllowed"
|
|
|
|
isChecked={
|
|
|
|
realm?.duplicateEmailsAllowed &&
|
|
|
|
!realm?.loginWithEmailAllowed &&
|
|
|
|
!realm?.registrationEmailAsUsername
|
|
|
|
}
|
|
|
|
onChange={(value) => {
|
|
|
|
save({ ...realm, duplicateEmailsAllowed: value });
|
|
|
|
}}
|
|
|
|
isDisabled={
|
|
|
|
realm?.loginWithEmailAllowed ||
|
|
|
|
realm?.registrationEmailAsUsername
|
2021-04-19 11:41:07 +00:00
|
|
|
}
|
2021-05-03 20:00:12 +00:00
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("verifyEmail")}
|
|
|
|
fieldId="kc-verify-email"
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={t("verifyEmailHelpText")}
|
|
|
|
forLabel={t("verifyEmail")}
|
2021-07-12 14:09:14 +00:00
|
|
|
forID={t(`common:helpLabel`, { label: t("verifyEmail") })}
|
2021-04-19 11:41:07 +00:00
|
|
|
/>
|
2021-05-03 20:00:12 +00:00
|
|
|
}
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
|
|
|
<Switch
|
2021-07-12 14:09:14 +00:00
|
|
|
id="kc-verify-email-switch"
|
2021-05-03 20:00:12 +00:00
|
|
|
data-testid="verify-email-switch"
|
|
|
|
name="verifyEmail"
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
isChecked={realm?.verifyEmail}
|
|
|
|
onChange={(value) => {
|
|
|
|
save({ ...realm, verifyEmail: value });
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
</FormAccess>
|
2021-04-19 11:41:07 +00:00
|
|
|
</FormPanel>
|
|
|
|
</PageSection>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|