@@ -267,6 +267,41 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
267
267
expect ( loginRes . message ) . toEqual ( 'User email is not verified.' ) ;
268
268
} ) ;
269
269
270
+ it ( 'provides function arguments in verifyUserEmails on login' , async ( ) => {
271
+ const user = new Parse . User ( ) ;
272
+ user . setUsername ( 'user' ) ;
273
+ user . setPassword ( 'pass' ) ;
274
+ user . set ( 'email' , '[email protected] ' ) ;
275
+ await user . signUp ( ) ;
276
+
277
+ const verifyUserEmails = {
278
+ method : async ( params ) => {
279
+ expect ( params . object ) . toBeInstanceOf ( Parse . User ) ;
280
+ expect ( params . ip ) . toBeDefined ( ) ;
281
+ expect ( params . master ) . toBeDefined ( ) ;
282
+ expect ( params . installationId ) . toBeDefined ( ) ;
283
+ return true ;
284
+ } ,
285
+ } ;
286
+ const verifyUserEmailsSpy = spyOn ( verifyUserEmails , 'method' ) . and . callThrough ( ) ;
287
+ await reconfigureServer ( {
288
+ appName : 'test' ,
289
+ publicServerURL : 'http://localhost:1337/1' ,
290
+ verifyUserEmails : verifyUserEmails . method ,
291
+ preventLoginWithUnverifiedEmail : verifyUserEmails . method ,
292
+ preventSignupWithUnverifiedEmail : true ,
293
+ emailAdapter : MockEmailAdapterWithOptions ( {
294
+
295
+ apiKey : 'k' ,
296
+ domain : 'd' ,
297
+ } ) ,
298
+ } ) ;
299
+
300
+ const res = await Parse . User . logIn ( 'user' , 'pass' ) . catch ( e => e ) ;
301
+ expect ( res . code ) . toBe ( 205 ) ;
302
+ expect ( verifyUserEmailsSpy ) . toHaveBeenCalledTimes ( 2 ) ;
303
+ } ) ;
304
+
270
305
it ( 'allows user to login only after user clicks on the link to confirm email address if preventLoginWithUnverifiedEmail is set to true' , async ( ) => {
271
306
let sendEmailOptions ;
272
307
const emailAdapter = {
0 commit comments