@@ -463,7 +463,7 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
463
463
} ) ;
464
464
} ) ;
465
465
466
- it ( 'succeeds sending a password reset email if appName, publicServerURL, and email adapter are prodvided ' , done => {
466
+ it ( 'succeeds sending a password reset email if appName, publicServerURL, and email adapter are provided ' , done => {
467
467
reconfigureServer ( {
468
468
appName : 'coolapp' ,
469
469
publicServerURL : 'http://localhost:1337/1' ,
@@ -910,6 +910,65 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
910
910
} ) ;
911
911
} ) ;
912
912
913
+ it ( 'should redirect with username encoded on success page' , done => {
914
+ const user = new Parse . User ( ) ;
915
+ const emailAdapter = {
916
+ sendVerificationEmail : ( ) => Promise . resolve ( ) ,
917
+ sendPasswordResetEmail : options => {
918
+ request ( {
919
+ url : options . link ,
920
+ followRedirects : false ,
921
+ } ) . then ( response => {
922
+ expect ( response . status ) . toEqual ( 302 ) ;
923
+ const re = / h t t p : \/ \/ l o c a l h o s t : 8 3 7 8 \/ 1 \/ a p p s \/ c h o o s e _ p a s s w o r d \? t o k e n = ( [ a - z A - Z 0 - 9 ] + ) \& i d = t e s t \& u s e r n a m e = z x c v % 2 B 1 / ;
924
+ const match = response . text . match ( re ) ;
925
+ if ( ! match ) {
926
+ fail ( 'should have a token' ) ;
927
+ done ( ) ;
928
+ return ;
929
+ }
930
+ const token = match [ 1 ] ;
931
+
932
+ request ( {
933
+ url : 'http://localhost:8378/1/apps/test/request_password_reset' ,
934
+ method : 'POST' ,
935
+ body : { new_password : 'hello' , token, username : 'zxcv+1' } ,
936
+ headers : {
937
+ 'Content-Type' : 'application/x-www-form-urlencoded' ,
938
+ } ,
939
+ followRedirects : false ,
940
+ } ) . then ( response => {
941
+ expect ( response . status ) . toEqual ( 302 ) ;
942
+ expect ( response . text ) . toEqual (
943
+ 'Found. Redirecting to http://localhost:8378/1/apps/password_reset_success.html?username=zxcv%2B1'
944
+ ) ;
945
+ done ( ) ;
946
+ } ) ;
947
+ } ) ;
948
+ } ,
949
+ sendMail : ( ) => { } ,
950
+ } ;
951
+ reconfigureServer ( {
952
+ appName : 'emailing app' ,
953
+ verifyUserEmails : true ,
954
+ emailAdapter : emailAdapter ,
955
+ publicServerURL : 'http://localhost:8378/1' ,
956
+ } ) . then ( ( ) => {
957
+ user . setPassword ( 'asdf' ) ;
958
+ user . setUsername ( 'zxcv+1' ) ;
959
+ user . set ( 'email' , '[email protected] ' ) ;
960
+ user . signUp ( ) . then ( ( ) => {
961
+ Parse . User . requestPasswordReset ( '[email protected] ' , {
962
+ error : err => {
963
+ jfail ( err ) ;
964
+ fail ( 'Should not fail' ) ;
965
+ done ( ) ;
966
+ } ,
967
+ } ) ;
968
+ } ) ;
969
+ } ) ;
970
+ } ) ;
971
+
913
972
it ( 'should programmatically reset password on ajax request' , async done => {
914
973
const user = new Parse . User ( ) ;
915
974
const emailAdapter = {
0 commit comments