-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1726 from SUNET/dev-2024-4
Update reset password, signup
- Loading branch information
Showing
47 changed files
with
816 additions
and
813 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ export const emailPlaceHolder = "[email protected]"; | |
|
||
interface EmailInputProps { | ||
required: boolean; | ||
autoFocus: boolean; | ||
autoFocus?: boolean; | ||
name: string; | ||
autoComplete?: "username"; | ||
helpBlock?: React.ReactNode; // help text shown above input | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { ExtraSecurityAlternatives } from "apis/eduidResetPassword"; | ||
import CustomInput from "components/Common/CustomInput"; | ||
import EduIDButton from "components/Common/EduIDButton"; | ||
import { GoBackButton } from "components/ResetPassword/GoBackButton"; | ||
import { FormApi, SubmissionErrors } from "final-form"; | ||
import { emptyStringPattern } from "helperFunctions/validation/regexPatterns"; | ||
import { Field as FinalField, Form as FinalForm } from "react-final-form"; | ||
import { FormattedMessage } from "react-intl"; | ||
|
||
const newPasswordFormId = "new-password-form"; | ||
|
||
export interface NewPasswordFormData { | ||
newPassword?: string; | ||
} | ||
|
||
interface NewPasswordFormProps { | ||
readonly goBack?: () => void; | ||
readonly extra_security?: ExtraSecurityAlternatives; | ||
readonly suggested_password: string | undefined; | ||
readonly submitNewPasswordForm: ( | ||
values: NewPasswordFormData, | ||
form: FormApi<NewPasswordFormData, Partial<NewPasswordFormData>>, | ||
callback?: ((errors?: SubmissionErrors) => void) | undefined | ||
) => void | Promise<void>; | ||
readonly submitButtonText: React.ReactChild; | ||
} | ||
|
||
export function NewPasswordForm(props: NewPasswordFormProps): JSX.Element { | ||
function validateNewPassword(values: NewPasswordFormData) { | ||
const newPassword = values.newPassword; | ||
const errors: NewPasswordFormData = {}; | ||
|
||
if (!newPassword || emptyStringPattern.test(newPassword)) { | ||
errors.newPassword = "required"; | ||
} else if (newPassword?.replace(/\s/g, "") !== props.suggested_password?.replace(/\s/g, "")) { | ||
// Remove whitespace from both passwords before comparing | ||
errors.newPassword = "chpass.different-repeat"; | ||
} | ||
return errors; | ||
} | ||
|
||
return ( | ||
<FinalForm<NewPasswordFormData> | ||
onSubmit={props.submitNewPasswordForm} | ||
validate={validateNewPassword} | ||
render={(formProps) => { | ||
return ( | ||
<form id={newPasswordFormId} onSubmit={formProps.handleSubmit}> | ||
<FinalField | ||
id="new-password" | ||
type="text" | ||
name="newPassword" | ||
component={CustomInput} | ||
required={true} | ||
label={<FormattedMessage defaultMessage="Repeat new password" description="Set new password" />} | ||
placeholder="xxxx xxxx xxxx" | ||
autoFocus={true} | ||
/> | ||
|
||
<div className="buttons"> | ||
{props.extra_security && Object.keys(props.extra_security).length > 0 && ( | ||
<GoBackButton onClickHandler={props.goBack} /> | ||
)} | ||
<EduIDButton buttonstyle="primary" id="new-password-button" disabled={formProps.invalid}> | ||
{props.submitButtonText} | ||
</EduIDButton> | ||
</div> | ||
</form> | ||
); | ||
}} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.