@@ -703,23 +703,27 @@ class SignInFuture implements SignInFutureResource {
703
703
} ) ;
704
704
}
705
705
706
+ private async _create ( params : SignInFutureCreateParams ) : Promise < void > {
707
+ await this . resource . __internal_basePost ( {
708
+ path : this . resource . pathRoot ,
709
+ body : params ,
710
+ } ) ;
711
+ }
712
+
706
713
async create ( params : SignInFutureCreateParams ) : Promise < { error : unknown } > {
707
714
return runAsyncResourceTask ( this . resource , async ( ) => {
708
- await this . resource . __internal_basePost ( {
709
- path : this . resource . pathRoot ,
710
- body : params ,
711
- } ) ;
715
+ await this . _create ( params ) ;
712
716
} ) ;
713
717
}
714
718
715
719
async password ( params : SignInFuturePasswordParams ) : Promise < { error : unknown } > {
716
- if ( [ params . identifier , params . email , params . phoneNumber ] . filter ( Boolean ) . length > 1 ) {
717
- throw new Error ( 'Only one of identifier, email , or phoneNumber can be provided' ) ;
720
+ if ( [ params . identifier , params . emailAddress , params . phoneNumber ] . filter ( Boolean ) . length > 1 ) {
721
+ throw new Error ( 'Only one of identifier, emailAddress , or phoneNumber can be provided' ) ;
718
722
}
719
723
720
724
return runAsyncResourceTask ( this . resource , async ( ) => {
721
725
// TODO @userland -errors:
722
- const identifier = params . identifier || params . email || params . phoneNumber ;
726
+ const identifier = params . identifier || params . emailAddress || params . phoneNumber ;
723
727
const previousIdentifier = this . resource . identifier ;
724
728
await this . resource . __internal_basePost ( {
725
729
path : this . resource . pathRoot ,
@@ -744,7 +748,7 @@ class SignInFuture implements SignInFutureResource {
744
748
745
749
return runAsyncResourceTask ( this . resource , async ( ) => {
746
750
if ( emailAddress ) {
747
- await this . create ( { identifier : emailAddress } ) ;
751
+ await this . _create ( { identifier : emailAddress } ) ;
748
752
}
749
753
750
754
const emailCodeFactor = this . selectFirstFactor ( { strategy : 'email_code' , emailAddressId } ) ;
@@ -785,7 +789,7 @@ class SignInFuture implements SignInFutureResource {
785
789
786
790
return runAsyncResourceTask ( this . resource , async ( ) => {
787
791
if ( emailAddress ) {
788
- await this . create ( { identifier : emailAddress } ) ;
792
+ await this . _create ( { identifier : emailAddress } ) ;
789
793
}
790
794
791
795
const emailLinkFactor = this . selectFirstFactor ( { strategy : 'email_link' , emailAddressId } ) ;
@@ -848,7 +852,7 @@ class SignInFuture implements SignInFutureResource {
848
852
849
853
return runAsyncResourceTask ( this . resource , async ( ) => {
850
854
if ( phoneNumber ) {
851
- await this . create ( { identifier : phoneNumber } ) ;
855
+ await this . _create ( { identifier : phoneNumber } ) ;
852
856
}
853
857
854
858
const phoneCodeFactor = this . selectFirstFactor ( { strategy : 'phone_code' , phoneNumberId } ) ;
@@ -880,14 +884,19 @@ class SignInFuture implements SignInFutureResource {
880
884
throw new Error ( 'modal flow is not supported yet' ) ;
881
885
}
882
886
883
- if ( ! this . resource . id ) {
884
- await this . create ( {
885
- strategy,
886
- redirectUrl : SignIn . clerk . buildUrlWithAuth ( redirectCallbackUrl ) ,
887
- actionCompleteRedirectUrl : redirectUrl ,
888
- } ) ;
887
+ let actionCompleteRedirectUrl = redirectUrl ;
888
+ try {
889
+ new URL ( redirectUrl ) ;
890
+ } catch {
891
+ actionCompleteRedirectUrl = window . location . origin + redirectUrl ;
889
892
}
890
893
894
+ await this . _create ( {
895
+ strategy,
896
+ redirectUrl : SignIn . clerk . buildUrlWithAuth ( redirectCallbackUrl ) ,
897
+ actionCompleteRedirectUrl,
898
+ } ) ;
899
+
891
900
const { status, externalVerificationRedirectURL } = this . resource . firstFactorVerification ;
892
901
893
902
if ( status === 'unverified' && externalVerificationRedirectURL ) {
@@ -924,7 +933,7 @@ class SignInFuture implements SignInFutureResource {
924
933
throw new Error ( `Unsupported Web3 provider: ${ provider } ` ) ;
925
934
}
926
935
927
- await this . create ( { identifier } ) ;
936
+ await this . _create ( { identifier } ) ;
928
937
929
938
const web3FirstFactor = this . resource . supportedFirstFactors ?. find (
930
939
f => f . strategy === strategy ,
0 commit comments