-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
installationId
, ip
, resendRequest
to arguments passed…
… to `verifyUserEmails` on verification email request (#8873) BREAKING CHANGE: The `Parse.User` passed as argument if `verifyUserEmails` is set to a function is renamed from `user` to `object` for consistency with invocations of `verifyUserEmails` on signup or login; the user object is not a plain JavaScript object anymore but an instance of `Parse.User`
- Loading branch information
Showing
3 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
const Auth = require('../lib/Auth'); | ||
const Config = require('../lib/Config'); | ||
const request = require('../lib/request'); | ||
const MockEmailAdapterWithOptions = require('./support/MockEmailAdapterWithOptions'); | ||
|
||
describe('Email Verification Token Expiration: ', () => { | ||
it('show the invalid verification link page, if the user clicks on the verify email link after the email verify token expires', done => { | ||
|
@@ -794,6 +795,41 @@ describe('Email Verification Token Expiration: ', () => { | |
}); | ||
}); | ||
|
||
it('provides function arguments in verifyUserEmails on verificationEmailRequest', async () => { | ||
const user = new Parse.User(); | ||
user.setUsername('user'); | ||
user.setPassword('pass'); | ||
user.set('email', '[email protected]'); | ||
await user.signUp(); | ||
|
||
const verifyUserEmails = { | ||
method: async (params) => { | ||
expect(params.object).toBeInstanceOf(Parse.User); | ||
expect(params.ip).toBeDefined(); | ||
expect(params.master).toBeDefined(); | ||
expect(params.installationId).toBeDefined(); | ||
expect(params.resendRequest).toBeTrue(); | ||
return true; | ||
}, | ||
}; | ||
const verifyUserEmailsSpy = spyOn(verifyUserEmails, 'method').and.callThrough(); | ||
await reconfigureServer({ | ||
appName: 'test', | ||
publicServerURL: 'http://localhost:1337/1', | ||
verifyUserEmails: verifyUserEmails.method, | ||
preventLoginWithUnverifiedEmail: verifyUserEmails.method, | ||
preventSignupWithUnverifiedEmail: true, | ||
emailAdapter: MockEmailAdapterWithOptions({ | ||
fromAddress: '[email protected]', | ||
apiKey: 'k', | ||
domain: 'd', | ||
}), | ||
}); | ||
|
||
await expectAsync(Parse.User.requestEmailVerification('[email protected]')).toBeResolved(); | ||
expect(verifyUserEmailsSpy).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('should throw with invalid emailVerifyTokenReuseIfValid', async done => { | ||
const sendEmailOptions = []; | ||
const emailAdapter = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters