This repository was archived by the owner on Apr 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
webapp_frontend/src/components/pages Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -69,19 +69,21 @@ export default function Registration(): ReactElement {
69
69
}
70
70
}
71
71
72
- const makePasswordInputFitRules = ( input :string ) :string | null => {
72
+ const makePasswordInputFitRules = ( input :string ) :[ string , boolean ] => {
73
73
input = deleteSpaces ( input ) ;
74
74
if ( biggerMaxStrLength ( input , MAX_PASSWORD_LENGTH ) ) {
75
- return null
75
+ return [ input , false ] ;
76
76
}
77
- return input ;
77
+ return [ input , true ] ;
78
78
}
79
79
80
80
const handlePasswordChange = ( event : ChangeEvent < HTMLInputElement > ) => {
81
81
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 ] ) {
84
84
value = password ;
85
+ } else {
86
+ value = value [ 0 ]
85
87
}
86
88
setPasswordInformationLength ( ! notMinStrLength ( value , MIN_PASSWORD_LENGTH ) ) ;
87
89
setPasswordInformationLowercase ( value . match ( / [ a - z ] / ) !== null ) ;
@@ -92,9 +94,11 @@ export default function Registration(): ReactElement {
92
94
93
95
const handlePasswordConfirmationChange = async ( event : ChangeEvent < HTMLInputElement > ) => {
94
96
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 ] ) {
97
99
value = passwordConfirmation ;
100
+ } else {
101
+ value = value [ 0 ]
98
102
}
99
103
setPasswordConfirmation ( value ) ;
100
104
}
You can’t perform that action at this time.
0 commit comments