Skip to content

Commit c25214e

Browse files
authored
customer_dashboard: set password max length to sign-in password input (#409)
* customer_dashboard: set password max length to sign-in password input * customer_dashboard: fix silent password truncation on reset forms * customer_dashboard: set password max length to sign-in password input
1 parent b2b2349 commit c25214e

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

apps/customer_dashboard/src/app/users/forgot_password/page.tsx

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,18 @@ export default function ForgotPasswordPage() {
364364
placeholder="Enter new password"
365365
value={password}
366366
onChange={(e) => {
367-
setPassword(e.target.value);
368-
resetError();
367+
const value = e.target.value;
368+
setPassword(value);
369+
if (value.length > PASSWORD_MAX_LENGTH) {
370+
setError(
371+
`Password must be at most ${PASSWORD_MAX_LENGTH} characters`,
372+
);
373+
} else {
374+
resetError();
375+
}
369376
}}
370377
fullWidth
371378
requiredSymbol
372-
maxLength={PASSWORD_MAX_LENGTH}
373379
helpText={
374380
error
375381
? undefined
@@ -392,12 +398,18 @@ export default function ForgotPasswordPage() {
392398
placeholder="Confirm password"
393399
value={confirmPassword}
394400
onChange={(e) => {
395-
setConfirmPassword(e.target.value);
396-
resetError();
401+
const value = e.target.value;
402+
setConfirmPassword(value);
403+
if (value.length > PASSWORD_MAX_LENGTH) {
404+
setError(
405+
`Password must be at most ${PASSWORD_MAX_LENGTH} characters`,
406+
);
407+
} else {
408+
resetError();
409+
}
397410
}}
398411
fullWidth
399412
requiredSymbol
400-
maxLength={PASSWORD_MAX_LENGTH}
401413
SideComponent={
402414
<button
403415
type="button"
@@ -440,7 +452,13 @@ export default function ForgotPasswordPage() {
440452
<Button
441453
type="submit"
442454
fullWidth
443-
disabled={!password || !confirmPassword || isLoading}
455+
disabled={
456+
!password ||
457+
!confirmPassword ||
458+
isLoading ||
459+
password.length > PASSWORD_MAX_LENGTH ||
460+
confirmPassword.length > PASSWORD_MAX_LENGTH
461+
}
444462
>
445463
{isLoading ? "Updating..." : "Update"}
446464
</Button>

apps/customer_dashboard/src/components/reset_password/reset_password.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export const ResetPassword: FC<ResetPasswordProps> = ({ isAfterLogin }) => {
6969
placeholder="Enter new password"
7070
requiredSymbol
7171
type={showNewPassword ? "text" : "password"}
72-
maxLength={PASSWORD_MAX_LENGTH}
7372
helpText={
7473
errors.newPassword
7574
? ""
@@ -96,7 +95,6 @@ export const ResetPassword: FC<ResetPasswordProps> = ({ isAfterLogin }) => {
9695
placeholder="Confirm password"
9796
requiredSymbol
9897
type={showConfirmPassword ? "text" : "password"}
99-
maxLength={PASSWORD_MAX_LENGTH}
10098
error={errors.confirmPassword?.message}
10199
fullWidth
102100
SideComponent={

apps/customer_dashboard/src/components/sign_in_form/sign_in_form.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type { FC } from "react";
1111

1212
import styles from "./sign_in_form.module.scss";
1313
import { useSignInForm } from "./use_sign_in_form";
14+
import { PASSWORD_MAX_LENGTH } from "@oko-wallet-ct-dashboard/constants";
1415
import { AccountForm } from "@oko-wallet-ct-dashboard/ui";
1516

1617
export const SignInForm: FC = () => {
@@ -54,6 +55,7 @@ export const SignInForm: FC = () => {
5455
type="password"
5556
placeholder="Password"
5657
fullWidth
58+
maxLength={PASSWORD_MAX_LENGTH}
5759
error={errors.password?.message}
5860
resetError={() => resetErrors("password")}
5961
{...register("password")}

0 commit comments

Comments
 (0)