@@ -273,33 +273,27 @@ export class SignIn extends BaseResource implements SignInResource {
273273 clerkVerifyEmailAddressCalledBeforeCreate ( 'SignIn' ) ;
274274 }
275275
276- const params : PrepareFirstFactorParams | PrepareSecondFactorParams = {
276+ const emailLinkParams : EmailLinkConfig = {
277277 strategy : 'email_link' ,
278- emailAddressId : emailAddressId ,
279- redirectUrl : redirectUrl ,
278+ emailAddressId,
279+ redirectUrl,
280280 } ;
281+ const isSecondFactor = this . status === 'needs_second_factor' ;
282+ const verificationKey : 'firstFactorVerification' | 'secondFactorVerification' = isSecondFactor
283+ ? 'secondFactorVerification'
284+ : 'firstFactorVerification' ;
281285
282- const verification : {
283- prepareFn : typeof SignIn . prototype . prepareSecondFactor | typeof SignIn . prototype . prepareFirstFactor ;
284- key : 'firstFactorVerification' | 'secondFactorVerification' ;
285- } =
286- this . status === 'needs_second_factor'
287- ? {
288- prepareFn : this . prepareSecondFactor ,
289- key : 'secondFactorVerification' ,
290- }
291- : {
292- prepareFn : this . prepareFirstFactor ,
293- key : 'firstFactorVerification' ,
294- } ;
295-
296- await verification . prepareFn ( params ) ;
286+ if ( isSecondFactor ) {
287+ await this . prepareSecondFactor ( emailLinkParams ) ;
288+ } else {
289+ await this . prepareFirstFactor ( emailLinkParams ) ;
290+ }
297291
298292 return new Promise ( ( resolve , reject ) => {
299293 void run ( ( ) => {
300294 return this . reload ( )
301295 . then ( res => {
302- const status = res [ verification . key ] . status ;
296+ const status = res [ verificationKey ] . status ;
303297 if ( status === 'verified' || status === 'expired' ) {
304298 stop ( ) ;
305299 resolve ( res ) ;
0 commit comments