Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 2946bb4

Browse files
committed
fixed error which prevented user from cleaning password field
1 parent 3eea39f commit 2946bb4

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

webapp_frontend/src/components/pages/Registration.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,21 @@ export default function Registration(): ReactElement {
6969
}
7070
}
7171

72-
const makePasswordInputFitRules = (input:string):string|null => {
72+
const makePasswordInputFitRules = (input:string):[string,boolean] => {
7373
input = deleteSpaces(input);
7474
if (biggerMaxStrLength(input, MAX_PASSWORD_LENGTH)){
75-
return null
75+
return [input,false];
7676
}
77-
return input;
77+
return [input,true];
7878
}
7979

8080
const handlePasswordChange = (event: ChangeEvent<HTMLInputElement>) => {
8181
event.preventDefault();
82-
let value:string|null = makePasswordInputFitRules(event.target.value);
83-
if (!value){
82+
let value:[string,boolean]|string = makePasswordInputFitRules(event.target.value);
83+
if (!value[1]){
8484
value = password;
85+
} else {
86+
value = value[0]
8587
}
8688
setPasswordInformationLength(!notMinStrLength(value, MIN_PASSWORD_LENGTH));
8789
setPasswordInformationLowercase(value.match(/[a-z]/) !== null);
@@ -92,9 +94,11 @@ export default function Registration(): ReactElement {
9294

9395
const handlePasswordConfirmationChange = async (event: ChangeEvent<HTMLInputElement>) => {
9496
event.preventDefault();
95-
let value:string|null = makePasswordInputFitRules(event.target.value);
96-
if (!value){
97+
let value:[string,boolean]|string = makePasswordInputFitRules(event.target.value);
98+
if (!value[1]){
9799
value = passwordConfirmation;
100+
} else {
101+
value = value[0]
98102
}
99103
setPasswordConfirmation(value);
100104
}

0 commit comments

Comments
 (0)