Skip to content

Commit

Permalink
fix(authenticator): force new password header and footer (#4235)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanksdesign authored Jul 18, 2023
1 parent f2ff87f commit c3a418d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .changeset/quiet-vans-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@aws-amplify/ui-react": patch
---

fix(authenticator-react): force new password header and footer

Adding Header and Footer components to ForceNewPassword screen
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export const ForceNewPassword = ({
const {
components: {
// @ts-ignore
ForceNewPassword: { FormFields = ForceNewPassword.FormFields },
ForceNewPassword: {
FormFields = ForceNewPassword.FormFields,
Header = ForceNewPassword.Header,
Footer = ForceNewPassword.Footer,
},
},
} = useCustomComponents();

Expand All @@ -42,7 +46,7 @@ export const ForceNewPassword = ({
onBlur={handleBlur}
>
<Flex as="fieldset" direction="column" isDisabled={isPending}>
<Heading level={3}>{getChangePasswordText()}</Heading>
<Header />

<FormFields />

Expand All @@ -66,12 +70,22 @@ export const ForceNewPassword = ({
>
{getBackToSignInText()}
</Button>

<Footer />
</Flex>
</form>
</RouteContainer>
);
};

ForceNewPassword.FormFields = function FormFields() {
ForceNewPassword.FormFields = function FormFields(): JSX.Element | null {
return <DefaultFormFields />;
};

ForceNewPassword.Header = function Header(): JSX.Element | null {
return <Heading level={4}>{getChangePasswordText()}</Heading>;
};

ForceNewPassword.Footer = function Footer(): JSX.Element | null {
return null;
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ import { ConfirmResetPassword, ResetPassword } from '../../ResetPassword';

// use the very generic name of Components as this is a temporary interface and is not exported
interface Components {
Footer?: () => JSX.Element;
FormFields?: () => JSX.Element;
Header?: () => JSX.Element;
Footer?: () => JSX.Element | null;
FormFields?: () => JSX.Element | null;
Header?: () => JSX.Element | null;
}

export interface DefaultComponents extends Omit<Components, 'FormFields'> {
ConfirmSignIn?: Omit<Components, 'FormFields'>;
ConfirmSignUp?: Omit<Components, 'FormFields'>;
ConfirmResetPassword?: Omit<Components, 'FormFields'>;
ConfirmVerifyUser?: Omit<Components, 'FormFields'>;
ForceNewPassword?: Pick<Components, 'FormFields'>;
ForceNewPassword?: Components;
ResetPassword?: Omit<Components, 'FormFields'>;
SetupTOTP?: Omit<Components, 'FormFields'>;
SignIn?: Omit<Components, 'FormFields'>;
Expand Down Expand Up @@ -65,6 +65,8 @@ export const defaultComponents: DefaultComponents = {
Footer: ConfirmVerifyUser.Footer,
},
ForceNewPassword: {
Header: ForceNewPassword.Header,
Footer: ForceNewPassword.Footer,
FormFields: ForceNewPassword.FormFields,
},
ResetPassword: {
Expand Down

0 comments on commit c3a418d

Please sign in to comment.