@@ -127,6 +127,7 @@ describe('Email Verification Token Expiration: ', () => {
127
127
user . set ( 'email' , '[email protected] ' ) ;
128
128
return user . signUp ( ) ;
129
129
} )
130
+ . then ( ( ) => jasmine . timeout ( ) )
130
131
. then ( ( ) => {
131
132
request ( {
132
133
url : sendEmailOptions . link ,
@@ -168,6 +169,7 @@ describe('Email Verification Token Expiration: ', () => {
168
169
user . set ( 'email' , '[email protected] ' ) ;
169
170
return user . signUp ( ) ;
170
171
} )
172
+ . then ( ( ) => jasmine . timeout ( ) )
171
173
. then ( ( ) => {
172
174
request ( {
173
175
url : sendEmailOptions . link ,
@@ -215,6 +217,7 @@ describe('Email Verification Token Expiration: ', () => {
215
217
user . set ( 'email' , '[email protected] ' ) ;
216
218
return user . signUp ( ) ;
217
219
} )
220
+ . then ( ( ) => jasmine . timeout ( ) )
218
221
. then ( ( ) => {
219
222
request ( {
220
223
url : sendEmailOptions . link ,
@@ -388,6 +391,7 @@ describe('Email Verification Token Expiration: ', () => {
388
391
user2 . setPassword ( 'expiringToken' ) ;
389
392
user2 . set ( 'email' , '[email protected] ' ) ;
390
393
await user2 . signUp ( ) ;
394
+ await jasmine . timeout ( ) ;
391
395
expect ( user2 . getSessionToken ( ) ) . toBeUndefined ( ) ;
392
396
expect ( sendEmailOptions ) . toBeDefined ( ) ;
393
397
expect ( verifySpy ) . toHaveBeenCalledTimes ( 5 ) ;
@@ -422,10 +426,47 @@ describe('Email Verification Token Expiration: ', () => {
422
426
newUser . set ( 'email' , '[email protected] ' ) ;
423
427
await newUser . signUp ( ) ;
424
428
await Parse . User . requestEmailVerification ( '[email protected] ' ) ;
429
+ await jasmine . timeout ( ) ;
425
430
expect ( sendSpy ) . toHaveBeenCalledTimes ( 2 ) ;
426
431
expect ( emailSpy ) . toHaveBeenCalledTimes ( 0 ) ;
427
432
} ) ;
428
433
434
+ it ( 'provides full user object in email verification function on email and username change' , async ( ) => {
435
+ const emailAdapter = {
436
+ sendVerificationEmail : ( ) => { } ,
437
+ sendPasswordResetEmail : ( ) => Promise . resolve ( ) ,
438
+ sendMail : ( ) => { } ,
439
+ } ;
440
+ const sendVerificationEmail = {
441
+ method ( req ) {
442
+ expect ( req . user ) . toBeDefined ( ) ;
443
+ expect ( req . user . id ) . toBeDefined ( ) ;
444
+ expect ( req . user . get ( 'createdAt' ) ) . toBeDefined ( ) ;
445
+ expect ( req . user . get ( 'updatedAt' ) ) . toBeDefined ( ) ;
446
+ expect ( req . master ) . toBeDefined ( ) ;
447
+ return false ;
448
+ } ,
449
+ } ;
450
+ await reconfigureServer ( {
451
+ appName : 'emailVerifyToken' ,
452
+ verifyUserEmails : true ,
453
+ emailAdapter : emailAdapter ,
454
+ emailVerifyTokenValidityDuration : 5 ,
455
+ publicServerURL : 'http://localhost:8378/1' ,
456
+ sendUserEmailVerification : sendVerificationEmail . method ,
457
+ } ) ;
458
+ const user = new Parse . User ( ) ;
459
+ user . setPassword ( 'password' ) ;
460
+ user . setUsername ( '[email protected] ' ) ;
461
+ user . setEmail ( '[email protected] ' ) ;
462
+ await user . save ( null , { useMasterKey : true } ) ;
463
+
464
+ // Update email and username
465
+ user . setUsername ( '[email protected] ' ) ;
466
+ user . setEmail ( '[email protected] ' ) ;
467
+ await user . save ( null , { useMasterKey : true } ) ;
468
+ } ) ;
469
+
429
470
it ( 'beforeSave options do not change existing behaviour' , async ( ) => {
430
471
let sendEmailOptions ;
431
472
const emailAdapter = {
@@ -448,6 +489,7 @@ describe('Email Verification Token Expiration: ', () => {
448
489
newUser . setPassword ( 'expiringToken' ) ;
449
490
newUser . set ( 'email' , '[email protected] ' ) ;
450
491
await newUser . signUp ( ) ;
492
+ await jasmine . timeout ( ) ;
451
493
const response = await request ( {
452
494
url : sendEmailOptions . link ,
453
495
followRedirects : false ,
@@ -490,6 +532,7 @@ describe('Email Verification Token Expiration: ', () => {
490
532
user . set ( 'email' , '[email protected] ' ) ;
491
533
return user . signUp ( ) ;
492
534
} )
535
+ . then ( ( ) => jasmine . timeout ( ) )
493
536
. then ( ( ) => {
494
537
request ( {
495
538
url : sendEmailOptions . link ,
@@ -549,6 +592,7 @@ describe('Email Verification Token Expiration: ', () => {
549
592
user . set ( 'email' , '[email protected] ' ) ;
550
593
return user . signUp ( ) ;
551
594
} )
595
+ . then ( ( ) => jasmine . timeout ( ) )
552
596
. then ( ( ) => {
553
597
return request ( {
554
598
url : sendEmailOptions . link ,
@@ -766,6 +810,9 @@ describe('Email Verification Token Expiration: ', () => {
766
810
} )
767
811
. then ( response => {
768
812
expect ( response . status ) . toBe ( 200 ) ;
813
+ } )
814
+ . then ( ( ) => jasmine . timeout ( ) )
815
+ . then ( ( ) => {
769
816
expect ( sendVerificationEmailCallCount ) . toBe ( 2 ) ;
770
817
expect ( sendEmailOptions ) . toBeDefined ( ) ;
771
818
@@ -917,6 +964,7 @@ describe('Email Verification Token Expiration: ', () => {
917
964
'Content-Type' : 'application/json' ,
918
965
} ,
919
966
} ) ;
967
+ await jasmine . timeout ( ) ;
920
968
expect ( response . status ) . toBe ( 200 ) ;
921
969
expect ( sendVerificationEmailCallCount ) . toBe ( 2 ) ;
922
970
expect ( sendEmailOptions ) . toBeDefined ( ) ;
@@ -959,6 +1007,7 @@ describe('Email Verification Token Expiration: ', () => {
959
1007
user . set ( 'email' , '[email protected] ' ) ;
960
1008
return user . signUp ( ) ;
961
1009
} )
1010
+ . then ( ( ) => jasmine . timeout ( ) )
962
1011
. then ( ( ) => {
963
1012
return request ( {
964
1013
url : sendEmailOptions . link ,
@@ -1197,6 +1246,7 @@ describe('Email Verification Token Expiration: ', () => {
1197
1246
user . set ( 'email' , '[email protected] ' ) ;
1198
1247
return user . signUp ( ) ;
1199
1248
} )
1249
+ . then ( ( ) => jasmine . timeout ( ) )
1200
1250
. then ( ( ) => {
1201
1251
request ( {
1202
1252
url : sendEmailOptions . link ,
0 commit comments