@@ -585,4 +585,83 @@ describe('Verify User Password', () => {
585
585
done ( ) ;
586
586
} ) ;
587
587
} ) ;
588
+
589
+ it ( 'verify password of user with unverified email with master key and ignoreEmailVerification=true' , async ( ) => {
590
+ await reconfigureServer ( {
591
+ publicServerURL : 'http://localhost:8378/' ,
592
+ appName : 'emailVerify' ,
593
+ verifyUserEmails : true ,
594
+ preventLoginWithUnverifiedEmail : true ,
595
+ emailAdapter : MockEmailAdapterWithOptions ( {
596
+
597
+ apiKey : 'k' ,
598
+ domain : 'd' ,
599
+ } ) ,
600
+ } ) ;
601
+
602
+ const user = new Parse . User ( ) ;
603
+ user . setUsername ( 'user' ) ;
604
+ user . setPassword ( 'pass' ) ;
605
+ user . setEmail ( '[email protected] ' ) ;
606
+ await user . signUp ( ) ;
607
+
608
+ const { data : res } = await request ( {
609
+ method : 'POST' ,
610
+ url : Parse . serverURL + '/verifyPassword' ,
611
+ headers : {
612
+ 'X-Parse-Master-Key' : Parse . masterKey ,
613
+ 'X-Parse-Application-Id' : Parse . applicationId ,
614
+ 'X-Parse-REST-API-Key' : 'rest' ,
615
+ 'Content-Type' : 'application/json' ,
616
+ } ,
617
+ body : {
618
+ username : 'user' ,
619
+ password : 'pass' ,
620
+ ignoreEmailVerification : true ,
621
+ } ,
622
+ json : true ,
623
+ } ) ;
624
+ expect ( res . objectId ) . toBe ( user . id ) ;
625
+ expect ( Object . prototype . hasOwnProperty . call ( res , 'sessionToken' ) ) . toEqual ( false ) ;
626
+ expect ( Object . prototype . hasOwnProperty . call ( res , 'password' ) ) . toEqual ( false ) ;
627
+ } ) ;
628
+
629
+ it ( 'fails to verify password of user with unverified email with master key and ignoreEmailVerification=false' , async ( ) => {
630
+ await reconfigureServer ( {
631
+ publicServerURL : 'http://localhost:8378/' ,
632
+ appName : 'emailVerify' ,
633
+ verifyUserEmails : true ,
634
+ preventLoginWithUnverifiedEmail : true ,
635
+ emailAdapter : MockEmailAdapterWithOptions ( {
636
+
637
+ apiKey : 'k' ,
638
+ domain : 'd' ,
639
+ } ) ,
640
+ } ) ;
641
+
642
+ const user = new Parse . User ( ) ;
643
+ user . setUsername ( 'user' ) ;
644
+ user . setPassword ( 'pass' ) ;
645
+ user . setEmail ( '[email protected] ' ) ;
646
+ await user . signUp ( ) ;
647
+
648
+ const res = await request ( {
649
+ method : 'POST' ,
650
+ url : Parse . serverURL + '/verifyPassword' ,
651
+ headers : {
652
+ 'X-Parse-Master-Key' : Parse . masterKey ,
653
+ 'X-Parse-Application-Id' : Parse . applicationId ,
654
+ 'X-Parse-REST-API-Key' : 'rest' ,
655
+ 'Content-Type' : 'application/json' ,
656
+ } ,
657
+ body : {
658
+ username : 'user' ,
659
+ password : 'pass' ,
660
+ ignoreEmailVerification : false ,
661
+ } ,
662
+ json : true ,
663
+ } ) . catch ( e => e ) ;
664
+ expect ( res . status ) . toBe ( 400 ) ;
665
+ expect ( res . text ) . toMatch ( / U s e r e m a i l i s n o t v e r i f i e d / ) ;
666
+ } ) ;
588
667
} ) ;
0 commit comments