-
-
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
Parse.User
as function parameter to Parse Server options …
…`verifyUserEmails`, `preventLoginWithUnverifiedEmail` on login (#8850)
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 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 |
---|---|---|
|
@@ -267,6 +267,41 @@ describe('Custom Pages, Email Verification, Password Reset', () => { | |
expect(loginRes.message).toEqual('User email is not verified.'); | ||
}); | ||
|
||
it('provides function arguments in verifyUserEmails on login', 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(); | ||
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', | ||
}), | ||
}); | ||
|
||
const res = await Parse.User.logIn('user', 'pass').catch(e => e); | ||
expect(res.code).toBe(205); | ||
expect(verifyUserEmailsSpy).toHaveBeenCalledTimes(2); | ||
}); | ||
|
||
it('allows user to login only after user clicks on the link to confirm email address if preventLoginWithUnverifiedEmail is set to true', async () => { | ||
let 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