-
Notifications
You must be signed in to change notification settings - Fork 0
feat(auth): update password reset page UI and policy #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mulldug
wants to merge
4
commits into
main
Choose a base branch
from
feat/new-password-restyle
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ba52678
feat(auth): update password reset page UI and policy
mulldug 8e3299e
fix(auth): accessibility and safety improvements to password reset page
mulldug 5eb77d2
test: update test passwords to meet 10-character minimum policy
mulldug 65506e9
style(auth): replace deprecated clip with clip-path in .sr_only
mulldug File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -248,7 +248,7 @@ private function createTestUsers(){ | |
| 'first_name' => 'Sebastian', | ||
| 'last_name' => 'Marcet', | ||
| 'email' => '[email protected]', | ||
| 'password' => '1Qaz2wsx!', | ||
| 'password' => '1Qaz2wsx!9', | ||
| 'password_enc' => \Auth\AuthHelper::AlgSHA1_V2_4, | ||
| 'gender' => 'male', | ||
| 'address1' => 'Av. Siempre Viva 111', | ||
|
|
@@ -269,7 +269,7 @@ private function createTestUsers(){ | |
| 'first_name' => 'Sebastian', | ||
| 'last_name' => 'Marcet IDN', | ||
| 'email' => 'hei@やる.ca', | ||
| 'password' => '1Qaz2wsx!', | ||
| 'password' => '1Qaz2wsx!9', | ||
| 'password_enc' => \Auth\AuthHelper::AlgSHA1_V2_4, | ||
| 'gender' => 'male', | ||
| 'address1' => 'Av. Siempre Viva 111', | ||
|
|
@@ -290,7 +290,7 @@ private function createTestUsers(){ | |
| 'first_name' => 'Márton', | ||
| 'last_name' => 'Kiss', | ||
| 'email' => '[email protected]', | ||
| 'password' => '1Qaz2wsx!', | ||
| 'password' => '1Qaz2wsx!9', | ||
| 'password_enc' => \Auth\AuthHelper::AlgSHA1_V2_4, | ||
| 'gender' => 'male', | ||
| 'address1' => 'Av. Siempre Viva 111', | ||
|
|
@@ -311,7 +311,7 @@ private function createTestUsers(){ | |
| 'first_name' => '付', | ||
| 'last_name' => '金刚', | ||
| 'email' => '[email protected]', | ||
| 'password' => '1Qaz2wsx!', | ||
| 'password' => '1Qaz2wsx!9', | ||
| 'password_enc' => \Auth\AuthHelper::AlgSHA1_V2_4, | ||
| 'gender' => 'male', | ||
| 'address1' => 'Av. Siempre Viva 111', | ||
|
|
@@ -332,7 +332,7 @@ private function createTestUsers(){ | |
| 'first_name' => 'Bharath', | ||
| 'last_name' => 'Kumar M R', | ||
| 'email' => '[email protected]', | ||
| 'password' => '1Qaz2wsx!', | ||
| 'password' => '1Qaz2wsx!9', | ||
| 'password_enc' => \Auth\AuthHelper::AlgSHA1_V2_4, | ||
| 'gender' => 'male', | ||
| 'address1' => 'Av. Siempre Viva 111', | ||
|
|
@@ -353,7 +353,7 @@ private function createTestUsers(){ | |
| 'first_name' => '大塚', | ||
| 'last_name' => '元央', | ||
| 'email' => '[email protected]', | ||
| 'password' => '1Qaz2wsx!', | ||
| 'password' => '1Qaz2wsx!9', | ||
| 'password_enc' => \Auth\AuthHelper::AlgSHA1_V2_4, | ||
| 'gender' => 'male', | ||
| 'address1' => 'Av. Siempre Viva 111', | ||
|
|
@@ -374,7 +374,7 @@ private function createTestUsers(){ | |
| 'first_name' => 'Ian Y.', | ||
| 'last_name' => 'Choi', | ||
| 'email' => '[email protected]', | ||
| 'password' => '1Qaz2wsx!', | ||
| 'password' => '1Qaz2wsx!9', | ||
| 'password_enc' => \Auth\AuthHelper::AlgSHA1_V2_4, | ||
| 'gender' => 'male', | ||
| 'address1' => 'Av. Siempre Viva 111', | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -8,7 +8,14 @@ import CardContent from "@material-ui/core/CardContent"; | |
| import Container from "@material-ui/core/Container"; | ||
| import CssBaseline from "@material-ui/core/CssBaseline"; | ||
| import Grid from "@material-ui/core/Grid"; | ||
| import IconButton from "@material-ui/core/IconButton"; | ||
| import InputAdornment from "@material-ui/core/InputAdornment"; | ||
| import InfoOutlinedIcon from "@material-ui/icons/InfoOutlined"; | ||
| import Visibility from "@material-ui/icons/Visibility"; | ||
| import VisibilityOff from "@material-ui/icons/VisibilityOff"; | ||
| import CheckCircle from "@material-ui/icons/CheckCircle"; | ||
| import Cancel from "@material-ui/icons/Cancel"; | ||
| import RadioButtonUnchecked from "@material-ui/icons/RadioButtonUnchecked"; | ||
| import PasswordStrengthBar from "react-password-strength-bar"; | ||
| import TextField from "@material-ui/core/TextField"; | ||
| import Typography from "@material-ui/core/Typography"; | ||
|
|
@@ -39,6 +46,7 @@ const ResetPasswordPage = ({ | |
| const formEl = useRef(null); | ||
| const captcha = useRef(null); | ||
| const [captchaConfirmation, setCaptchaConfirmation] = useState(null); | ||
| const [showPassword, setShowPassword] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| if (resetPasswordError) { | ||
|
|
@@ -76,6 +84,8 @@ const ResetPasswordPage = ({ | |
| } | ||
| }; | ||
|
|
||
| const passwordRequirementItems = passwordPolicy.shape_list.split(",").map(s => s.trim()); | ||
|
|
||
| return ( | ||
| <Container component="main" maxWidth="xs" className={styles.main_container}> | ||
| <CssBaseline /> | ||
|
|
@@ -94,8 +104,8 @@ const ResetPasswordPage = ({ | |
| > | ||
| <Card className={styles.reset_password_container} variant="outlined"> | ||
| <CardHeader | ||
| title="Reset your Password" | ||
| subheader="You can reset your password here." | ||
| title="Set a new password." | ||
| subheader="Resetting the password for the FNid below." | ||
| /> | ||
| <CardContent> | ||
| <Grid | ||
|
|
@@ -106,33 +116,49 @@ const ResetPasswordPage = ({ | |
| > | ||
| <Grid item> | ||
| <TextField | ||
| className={styles.email_field} | ||
| id="email" | ||
| name="email" | ||
| autoComplete="email" | ||
| variant="outlined" | ||
| variant="filled" | ||
| fullWidth | ||
| size="small" | ||
| label="Email Address" | ||
| hiddenLabel | ||
| value={formik.values.email} | ||
| disabled={true} | ||
| InputProps={{ disableUnderline: true }} | ||
| /> | ||
| </Grid> | ||
| <Grid item xs={12}> | ||
| <TextField | ||
| id="password" | ||
| name="password" | ||
| type="password" | ||
| type={showPassword ? "text" : "password"} | ||
| variant="outlined" | ||
| fullWidth | ||
| size="small" | ||
| label="Password" | ||
| label="New password" | ||
| inputProps={{maxLength: passwordPolicy.max_length}} | ||
| value={formik.values.password} | ||
| onChange={formik.handleChange} | ||
| error={ | ||
| formik.touched.password && Boolean(formik.errors.password) | ||
| } | ||
| helperText={formik.touched.password && formik.errors.password} | ||
| InputProps={{ | ||
| endAdornment: ( | ||
| <InputAdornment position="end"> | ||
| <IconButton | ||
| onClick={() => setShowPassword(!showPassword)} | ||
| edge="end" | ||
| size="small" | ||
| aria-label={showPassword ? "Hide password" : "Show password"} | ||
| > | ||
| {showPassword ? <VisibilityOff /> : <Visibility />} | ||
| </IconButton> | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| </InputAdornment> | ||
| ) | ||
| }} | ||
| /> | ||
| {formik.values.password && ( | ||
| <PasswordStrengthBar | ||
|
|
@@ -149,7 +175,7 @@ const ResetPasswordPage = ({ | |
| variant="outlined" | ||
| fullWidth | ||
| size="small" | ||
| label="Confirm Password" | ||
| label="Confirm password" | ||
| inputProps={{maxLength: passwordPolicy.max_length}} | ||
| value={formik.values.password_confirmation} | ||
| onChange={formik.handleChange} | ||
|
|
@@ -161,14 +187,37 @@ const ResetPasswordPage = ({ | |
| formik.touched.password_confirmation && | ||
| formik.errors.password_confirmation | ||
| } | ||
| InputProps={{ | ||
| endAdornment: ( | ||
| <InputAdornment position="end"> | ||
| {!formik.values.password_confirmation | ||
| ? <RadioButtonUnchecked style={{ color: '#ccc' }} /> | ||
| : formik.values.password_confirmation === formik.values.password && formik.values.password | ||
| ? <CheckCircle style={{ color: '#2e7d32' }} /> | ||
| : <Cancel style={{ color: '#c62828', opacity: 0.6 }} /> | ||
| } | ||
| <span className={styles.sr_only} aria-live="polite"> | ||
| {!formik.values.password_confirmation | ||
| ? "" | ||
| : formik.values.password_confirmation === formik.values.password && formik.values.password | ||
| ? "Passwords match" | ||
| : "Passwords do not match" | ||
| } | ||
| </span> | ||
| </InputAdornment> | ||
| ) | ||
| }} | ||
| /> | ||
| </Grid> | ||
| <Grid item className={styles.password_hint}> | ||
| <InfoOutlinedIcon fontSize="small"/> | ||
| | ||
| <Typography variant="body2"> | ||
| <div dangerouslySetInnerHTML={{ __html: `The Password must be ${passwordPolicy.min_length}–${passwordPolicy.max_length} characters, and ${passwordPolicy.shape_warning}` }} /> | ||
| </Typography> | ||
| <p>Your password must include:</p> | ||
| <ul> | ||
| <li key="length">{passwordPolicy.min_length}–{passwordPolicy.max_length} characters</li> | ||
| {passwordRequirementItems.map((item, index) => ( | ||
| <li key={index}>{item}</li> | ||
| ))} | ||
| </ul> | ||
| <p className={styles.password_characters}>Allowed: <span>{passwordPolicy.allowed_special_characters_text}</span></p> | ||
| </Grid> | ||
| <Grid item container alignItems="center" justifyContent="center"> | ||
| <Grid container item justify='center'> | ||
|
|
@@ -195,6 +244,11 @@ const ResetPasswordPage = ({ | |
| disableElevation | ||
| fullWidth | ||
| type="submit" | ||
| disabled={ | ||
| !!formik.errors.password || | ||
| !formik.values.password_confirmation || | ||
| formik.values.password_confirmation !== formik.values.password | ||
| } | ||
| > | ||
| {submitButtonText} | ||
| </Button> | ||
|
|
@@ -207,6 +261,7 @@ const ResetPasswordPage = ({ | |
| <input type="hidden" value={initialValues.email} id="email" name="email"/> | ||
| <input type="hidden" name="token" value={token}/> | ||
| </form> | ||
| <p className={styles.help_link}>Need help? <a href="mailto:[email protected]">[email protected]</a></p> | ||
| </Container> | ||
| ); | ||
| }; | ||
|
|
||
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.