-
-
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.
fix: Conditional email verification not working in some cases if `ver…
…ifyUserEmails`, `preventLoginWithUnverifiedEmail` set to functions (#8838)
- Loading branch information
Showing
5 changed files
with
62 additions
and
37 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
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 |
---|---|---|
|
@@ -242,6 +242,31 @@ describe('Custom Pages, Email Verification, Password Reset', () => { | |
}); | ||
}); | ||
|
||
it('prevents user from signup and login if email is not verified and preventLoginWithUnverifiedEmail is set to function returning true', async () => { | ||
await reconfigureServer({ | ||
appName: 'test', | ||
publicServerURL: 'http://localhost:1337/1', | ||
verifyUserEmails: async () => true, | ||
preventLoginWithUnverifiedEmail: async () => true, | ||
preventSignupWithUnverifiedEmail: true, | ||
emailAdapter: MockEmailAdapterWithOptions({ | ||
fromAddress: '[email protected]', | ||
apiKey: 'k', | ||
domain: 'd', | ||
}), | ||
}); | ||
|
||
const user = new Parse.User(); | ||
user.setPassword('asdf'); | ||
user.setUsername('zxcv'); | ||
user.set('email', '[email protected]'); | ||
const signupRes = await user.signUp(null).catch(e => e); | ||
expect(signupRes.message).toEqual('User email is not verified.'); | ||
|
||
const loginRes = await Parse.User.logIn('zxcv', 'asdf').catch(e => e); | ||
expect(loginRes.message).toEqual('User email is not verified.'); | ||
}); | ||
|
||
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
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