@@ -8,7 +8,7 @@ import { Navigate, useSearchParams } from 'react-router'
8
8
import { authWeakLogin } from 'citizen-frontend/auth/api'
9
9
import { wrapResult } from 'lib-common/api'
10
10
import { string } from 'lib-common/form/fields'
11
- import { object , required , validated } from 'lib-common/form/form'
11
+ import { object , required , validated , value } from 'lib-common/form/form'
12
12
import { useForm , useFormFields } from 'lib-common/form/hooks'
13
13
import { nonBlank } from 'lib-common/form/validators'
14
14
import { parseUrlWithOrigin } from 'lib-common/utils/parse-url-with-origin'
@@ -67,7 +67,8 @@ export default React.memo(function WeakLoginFormPage() {
67
67
68
68
const weakLoginForm = object ( {
69
69
username : validated ( required ( string ( ) ) , nonBlank ) ,
70
- password : validated ( required ( string ( ) ) , nonBlank )
70
+ // value<string> is used to avoid trimming
71
+ password : validated ( required ( value < string > ( ) ) , nonBlank )
71
72
} )
72
73
73
74
const authWeakLoginResult = wrapResult ( authWeakLogin )
@@ -134,9 +135,10 @@ const WeakLoginForm = React.memo(function WeakLogin({
134
135
type = "submit"
135
136
text = { t . link }
136
137
disabled = { ! form . isValid ( ) }
137
- onClick = { ( ) =>
138
- authWeakLoginResult ( form . state . username , form . state . password )
139
- }
138
+ onClick = { ( ) => {
139
+ const { username, password } = form . value ( )
140
+ return authWeakLoginResult ( username , password )
141
+ } }
140
142
onSuccess = { ( ) => window . location . replace ( nextUrl ?? '/' ) }
141
143
onFailure = { ( error ) => {
142
144
if ( error . statusCode === 429 ) {
0 commit comments