File tree Expand file tree Collapse file tree 5 files changed +59
-22
lines changed
clerk-js/src/core/resources Expand file tree Collapse file tree 5 files changed +59
-22
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ---
Original file line number Diff line number Diff line change @@ -635,12 +635,16 @@ class SignInFuture implements SignInFutureResource {
635635 }
636636
637637 async password ( params : SignInFuturePasswordParams ) : Promise < { error : unknown } > {
638- const { identifier, password } = params ;
638+ if ( [ params . identifier , params . email , params . phoneNumber ] . filter ( Boolean ) . length > 1 ) {
639+ throw new Error ( 'Only one of identifier, email, or phoneNumber can be provided' ) ;
640+ }
641+
639642 return runAsyncResourceTask ( this . resource , async ( ) => {
643+ const identifier = params . identifier || params . email || params . phoneNumber ;
640644 const previousIdentifier = this . resource . identifier ;
641645 await this . resource . __internal_basePost ( {
642646 path : this . resource . pathRoot ,
643- body : { identifier : identifier || previousIdentifier , password } ,
647+ body : { identifier : identifier || previousIdentifier , password : params . password } ,
644648 } ) ;
645649 } ) ;
646650 }
Original file line number Diff line number Diff line change @@ -595,21 +595,30 @@ class SignUpFuture implements SignUpFutureResource {
595595 }
596596
597597 async password ( params : SignUpFuturePasswordParams ) : Promise < { error : unknown } > {
598- const { emailAddress, password } = params ;
598+ if ( [ params . emailAddress , params . phoneNumber ] . filter ( Boolean ) . length > 1 ) {
599+ throw new Error ( 'Only one of emailAddress or phoneNumber can be provided' ) ;
600+ }
601+
599602 return runAsyncResourceTask ( this . resource , async ( ) => {
600603 const { captchaToken, captchaWidgetType, captchaError } = await this . getCaptchaToken ( ) ;
601604
602- await this . resource . __internal_basePost ( {
603- path : this . resource . pathRoot ,
604- body : {
605- strategy : 'password' ,
606- emailAddress,
607- password,
608- captchaToken,
609- captchaWidgetType,
610- captchaError,
611- } ,
612- } ) ;
605+ const body : Record < string , unknown > = {
606+ strategy : 'password' ,
607+ password : params . password ,
608+ captchaToken,
609+ captchaWidgetType,
610+ captchaError,
611+ } ;
612+
613+ if ( params . phoneNumber ) {
614+ body . phoneNumber = params . phoneNumber ;
615+ }
616+
617+ if ( params . emailAddress ) {
618+ body . emailAddress = params . emailAddress ;
619+ }
620+
621+ await this . resource . __internal_basePost ( { path : this . resource . pathRoot , body } ) ;
613622 } ) ;
614623 }
615624
Original file line number Diff line number Diff line change @@ -11,10 +11,25 @@ export interface SignInFutureCreateParams {
1111 transfer ?: boolean ;
1212}
1313
14- export interface SignInFuturePasswordParams {
15- identifier ?: string ;
16- password : string ;
17- }
14+ export type SignInFuturePasswordParams =
15+ | {
16+ identifier : string ;
17+ password : string ;
18+ email ?: never ;
19+ phoneNumber ?: never ;
20+ }
21+ | {
22+ password : string ;
23+ email : string ;
24+ identifier ?: never ;
25+ phoneNumber ?: never ;
26+ }
27+ | {
28+ password : string ;
29+ phoneNumber : string ;
30+ identifier ?: never ;
31+ email ?: never ;
32+ } ;
1833
1934export interface SignInFutureEmailCodeSendParams {
2035 email : string ;
Original file line number Diff line number Diff line change @@ -10,10 +10,17 @@ export interface SignUpFutureEmailCodeVerifyParams {
1010 code : string ;
1111}
1212
13- export interface SignUpFuturePasswordParams {
14- emailAddress : string ;
15- password : string ;
16- }
13+ export type SignUpFuturePasswordParams =
14+ | {
15+ emailAddress : string ;
16+ password : string ;
17+ phoneNumber ?: never ;
18+ }
19+ | {
20+ phoneNumber : string ;
21+ password : string ;
22+ emailAddress ?: never ;
23+ } ;
1724
1825export interface SignUpFuturePhoneCodeSendParams {
1926 phoneNumber ?: string ;
You can’t perform that action at this time.
0 commit comments