@@ -55,15 +55,8 @@ export function SignInWithEmailAndPassword({
55
55
56
56
return (
57
57
< FormProvider { ...formMethods } >
58
- < ClientOnly
59
- fallback = { < SignInWithEmailAndPasswordForm loading = { loading } /> }
60
- >
61
- { ( ) => (
62
- < ClientSignInWithEmailAndPasswordForm
63
- loading = { loading }
64
- signIn = { signIn }
65
- />
66
- ) }
58
+ < ClientOnly fallback = { < SignInWithEmailAndPasswordForm loading = { loading } /> } >
59
+ { ( ) => < ClientSignInWithEmailAndPasswordForm loading = { loading } signIn = { signIn } /> }
67
60
</ ClientOnly >
68
61
</ FormProvider >
69
62
) ;
@@ -87,12 +80,7 @@ function SignInWithEmailAndPasswordForm({
87
80
< FormItem className = "flex flex-col items-start gap-2" >
88
81
< FormLabel > { t ( 'auth:sign_in.email' ) } </ FormLabel >
89
82
< FormControl >
90
- < Input
91
- disabled = { ! hydrated }
92
- className = "w-full"
93
- type = "email"
94
- { ...field }
95
- />
83
+ < Input disabled = { ! hydrated } className = "w-full" type = "email" { ...field } />
96
84
</ FormControl >
97
85
< FormError />
98
86
</ FormItem >
@@ -117,11 +105,7 @@ function SignInWithEmailAndPasswordForm({
117
105
</ FormItem >
118
106
) }
119
107
/>
120
- < FormField
121
- control = { control }
122
- name = "credentials"
123
- render = { ( ) => < FormError /> }
124
- />
108
+ < FormField control = { control } name = "credentials" render = { ( ) => < FormError /> } />
125
109
< Button type = "submit" disabled = { ! hydrated } >
126
110
{ loading ? < Spinner className = "size-4" /> : t ( 'auth:sign_in' ) }
127
111
</ Button >
@@ -142,53 +126,50 @@ function ClientSignInWithEmailAndPasswordForm({
142
126
clientServices . authenticationClientService ,
143
127
) ;
144
128
145
- const { handleSubmit, setError, formState } =
146
- useFormContext < EmailAndPasswordFormValues > ( ) ;
129
+ const { handleSubmit, setError, formState } = useFormContext < EmailAndPasswordFormValues > ( ) ;
147
130
const navigate = useNavigate ( ) ;
148
131
149
- const handleEmailSignIn = handleSubmit (
150
- async ( { credentials : { email, password } } ) => {
151
- try {
152
- const result = await emailAndPasswordSignIn ( email , password ) ;
132
+ const handleEmailSignIn = handleSubmit ( async ( { credentials : { email, password } } ) => {
133
+ try {
134
+ const result = await emailAndPasswordSignIn ( email , password ) ;
153
135
154
- if ( ! result ) return ;
155
- const { idToken, csrf } = result ;
156
- if ( ! idToken ) return ;
157
- signIn ( { type : 'email' , idToken, csrf } ) ;
158
- // Hack to wait for the form to be submitted, otherwise the loading spinner will be flickering
159
- await sleep ( 1000 ) ;
160
- } catch ( error ) {
161
- if ( error instanceof EmailUnverified ) {
162
- navigate ( getRoute ( '/email-verification' ) ) ;
163
- } else if ( error instanceof UserNotFoundError ) {
164
- setError (
165
- 'credentials.email' ,
166
- {
167
- message : t ( 'auth:sign_in.errors.user_not_found' ) ,
168
- } ,
169
- { shouldFocus : true } ,
170
- ) ;
171
- } else if ( error instanceof WrongPasswordError ) {
172
- setError (
173
- 'credentials.password' ,
174
- {
175
- message : t ( 'auth:sign_in.errors.wrong_password_error' ) ,
176
- } ,
177
- { shouldFocus : true } ,
178
- ) ;
179
- } else if ( error instanceof InvalidLoginCredentials ) {
180
- setError ( 'credentials' , {
181
- message : t ( 'auth:sign_in.errors.invalid_login_credentials' ) ,
182
- } ) ;
183
- } else if ( error instanceof NetworkRequestFailed ) {
184
- toast . error ( t ( 'common:errors.firebase_network_error' ) ) ;
185
- } else {
186
- Sentry . captureException ( error ) ;
187
- toast . error ( t ( 'common:errors.unknown' ) ) ;
188
- }
136
+ if ( ! result ) return ;
137
+ const { idToken, csrf } = result ;
138
+ if ( ! idToken ) return ;
139
+ signIn ( { type : 'email' , idToken, csrf } ) ;
140
+ // Hack to wait for the form to be submitted, otherwise the loading spinner will be flickering
141
+ await sleep ( 1000 ) ;
142
+ } catch ( error ) {
143
+ if ( error instanceof EmailUnverified ) {
144
+ navigate ( getRoute ( '/email-verification' ) ) ;
145
+ } else if ( error instanceof UserNotFoundError ) {
146
+ setError (
147
+ 'credentials.email' ,
148
+ {
149
+ message : t ( 'auth:sign_in.errors.user_not_found' ) ,
150
+ } ,
151
+ { shouldFocus : true } ,
152
+ ) ;
153
+ } else if ( error instanceof WrongPasswordError ) {
154
+ setError (
155
+ 'credentials.password' ,
156
+ {
157
+ message : t ( 'auth:sign_in.errors.wrong_password_error' ) ,
158
+ } ,
159
+ { shouldFocus : true } ,
160
+ ) ;
161
+ } else if ( error instanceof InvalidLoginCredentials ) {
162
+ setError ( 'credentials' , {
163
+ message : t ( 'auth:sign_in.errors.invalid_login_credentials' ) ,
164
+ } ) ;
165
+ } else if ( error instanceof NetworkRequestFailed ) {
166
+ toast . error ( t ( 'common:errors.firebase_network_error' ) ) ;
167
+ } else {
168
+ Sentry . captureException ( error ) ;
169
+ toast . error ( t ( 'common:errors.unknown' ) ) ;
189
170
}
190
- } ,
191
- ) ;
171
+ }
172
+ } ) ;
192
173
193
174
return (
194
175
< SignInWithEmailAndPasswordForm
0 commit comments