Skip to content

Commit

Permalink
feat: add a password confirmation box
Browse files Browse the repository at this point in the history
There are users creating passwords and forget them right after.
  • Loading branch information
aalemayhu committed Jun 13, 2024
1 parent 7ef50a3 commit 73ac5ec
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/components/forms/RegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function RegisterForm({ setErrorMessage }: Props) {
const [email, setEmail] = useState(localStorage.getItem('email') || '');
const [tos, setTos] = useState(localStorage.getItem('tos') === 'true');
const [password, setPassword] = useState('');
const [confirmPassword, setConfirmPassword] = useState('');
const [loading, setLoading] = useState(false);

const isValid = () =>
Expand All @@ -24,7 +25,8 @@ function RegisterForm({ setErrorMessage }: Props) {
email.length > 0 &&
email.length < 256 &&
password.length > 7 &&
password.length < 256;
password.length < 256
&& password == confirmPassword;

Check failure on line 29 in src/components/forms/RegisterForm.tsx

View workflow job for this annotation

GitHub Actions / build (v18.16.0)

Expected '===' and instead saw '=='

const handleSubmit = async (event: SyntheticEvent) => {
event.preventDefault();
Expand Down Expand Up @@ -117,6 +119,22 @@ function RegisterForm({ setErrorMessage }: Props) {
/>
</div>
</label>
<label htmlFor="password" className="label">
Confirm Password
<div className="control">
<input
name="confirm_password"
min="8"
max="255"
value={confirmPassword}
onChange={(event) => setConfirmPassword(event.target.value)}
required
className="input"
type="password"
placeholder="Confirm password"
/>
</div>
</label>
</div>

<div className="field">
Expand Down

0 comments on commit 73ac5ec

Please sign in to comment.