-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
feat: Pass event information to verifyUserEmails
#9651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Vishal4real
wants to merge
18
commits into
parse-community:alpha
Choose a base branch
from
Vishal4real:FIX/Issue_9505
base: alpha
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2dbc4d7
FIX: Passed event information to verifyUserEmails
6a80811
Merge branch 'alpha' into FIX/Issue_9505
mtrezza f1e44c3
Merge branch 'alpha' into FIX/Issue_9505
Vishal4real 517bd62
Merge branch 'alpha' into FIX/Issue_9505
mtrezza 1a01272
feat: Pass event information to verifyUserEmails
69c03b1
Merge branch 'alpha' into FIX/Issue_9505
mtrezza d51c881
refactor: done suggested changes
80c0d34
refactor: rename EmailVerificationToken.spec.js to EmailVerification.…
7c8e0f5
Merge branch 'alpha' into FIX/Issue_9505
mtrezza f9a1766
refactor: revert unrelated formatings
9352467
Update index.js
Vishal4real 025503b
refactor: passed req along with authContext
9c5335d
Merge branch 'FIX/Issue_9505' of https://github.com/Vishal4real/parse…
98396f1
refactor: changes reverted in package-lock
8fe6c61
Merge branch 'alpha' into FIX/Issue_9505
mtrezza 6399ac6
Merge branch 'alpha' into FIX/Issue_9505
Vishal4real 93e4989
simplify
mtrezza 7565d9e
simplify
mtrezza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 { getAuthForSessionToken } = require('../lib/Auth'); | ||
const MockEmailAdapterWithOptions = require('./support/MockEmailAdapterWithOptions'); | ||
|
||
describe('Email Verification Token Expiration: ', () => { | ||
|
@@ -14,7 +15,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendEmailOptions = options; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -62,7 +63,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendEmailOptions = options; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -114,7 +115,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendEmailOptions = options; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -156,7 +157,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendEmailOptions = options; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -204,7 +205,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendEmailOptions = options; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -252,7 +253,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendEmailOptions = options; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -297,9 +298,9 @@ describe('Email Verification Token Expiration: ', () => { | |
it('can resend email using an expired token', async () => { | ||
const user = new Parse.User(); | ||
const emailAdapter = { | ||
sendVerificationEmail: () => {}, | ||
sendVerificationEmail: () => { }, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
await reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -359,7 +360,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendEmailOptions = options; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
const verifyUserEmails = { | ||
method(req) { | ||
|
@@ -418,7 +419,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendEmailOptions = options; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
const verifyUserEmails = { | ||
method(req) { | ||
|
@@ -459,9 +460,9 @@ describe('Email Verification Token Expiration: ', () => { | |
|
||
it_id('d812de87-33d1-495e-a6e8-3485f6dc3589')(it)('can conditionally send user email verification', async () => { | ||
const emailAdapter = { | ||
sendVerificationEmail: () => {}, | ||
sendVerificationEmail: () => { }, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
const sendVerificationEmail = { | ||
method(req) { | ||
|
@@ -493,9 +494,9 @@ describe('Email Verification Token Expiration: ', () => { | |
|
||
it_id('d98babc1-feb8-4b5e-916c-57dc0a6ed9fb')(it)('provides full user object in email verification function on email and username change', async () => { | ||
const emailAdapter = { | ||
sendVerificationEmail: () => {}, | ||
sendVerificationEmail: () => { }, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
const sendVerificationEmail = { | ||
method(req) { | ||
|
@@ -534,7 +535,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendEmailOptions = options; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
await reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -577,7 +578,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendEmailOptions = options; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -635,7 +636,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendEmailOptions = options; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
const serverConfig = { | ||
appName: 'emailVerifyToken', | ||
|
@@ -696,7 +697,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendEmailOptions = options; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
const serverConfig = { | ||
appName: 'emailVerifyToken', | ||
|
@@ -753,7 +754,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendEmailOptions = options; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
const serverConfig = { | ||
appName: 'emailVerifyToken', | ||
|
@@ -830,7 +831,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendVerificationEmailCallCount++; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -948,7 +949,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendPasswordResetEmail: options => { | ||
sendEmailOptions.push(options); | ||
}, | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
try { | ||
await reconfigureServer({ | ||
|
@@ -989,7 +990,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendVerificationEmailCallCount++; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
await reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -1056,7 +1057,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendVerificationEmailCallCount++; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -1117,7 +1118,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendVerificationEmailCallCount++; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -1163,7 +1164,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendVerificationEmailCallCount++; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -1208,7 +1209,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendVerificationEmailCallCount++; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -1252,7 +1253,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendEmailOptions = options; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -1295,7 +1296,7 @@ describe('Email Verification Token Expiration: ', () => { | |
sendEmailOptions = options; | ||
}, | ||
sendPasswordResetEmail: () => Promise.resolve(), | ||
sendMail: () => {}, | ||
sendMail: () => { }, | ||
}; | ||
reconfigureServer({ | ||
appName: 'emailVerifyToken', | ||
|
@@ -1351,3 +1352,62 @@ describe('Email Verification Token Expiration: ', () => { | |
}); | ||
}); | ||
}); | ||
|
||
describe('Auth Context', () => { | ||
let user; | ||
let config; | ||
|
||
beforeEach(async (done) => { | ||
await reconfigureServer({ | ||
verifyUserEmails: jasmine.createSpy('verifyUserEmails'), | ||
}); | ||
|
||
user = new Parse.User(); | ||
await user.signUp({ | ||
username: 'testuser', | ||
password: 'securepassword', | ||
mtrezza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
email: '[email protected]', | ||
}); | ||
|
||
config = Config.get('test'); | ||
}); | ||
|
||
it('should call verifyUserEmails with correct auth context on signup', async (done) => { | ||
const sessionToken = user.getSessionToken(); | ||
expect(sessionToken).toBeDefined(); | ||
|
||
await getAuthForSessionToken({ | ||
sessionToken, | ||
config, | ||
}); | ||
|
||
expect(config.verifyUserEmails).toHaveBeenCalledWith({ | ||
action: 'signup', | ||
authProvider: 'password', | ||
}); | ||
}); | ||
|
||
it('should call verifyUserEmails with correct auth context on login', async (done) => { | ||
await Parse.User.logIn('testuser', 'securepassword'); | ||
mtrezza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
expect(config.verifyUserEmails).toHaveBeenCalledWith({ | ||
action: 'login', | ||
authProvider: 'password', | ||
}); | ||
}); | ||
|
||
it('should call verifyUserEmails with correct provider for social login', async (done) => { | ||
const socialAuthData = { | ||
id: '1234567890', | ||
access_token: 'mockAccessToken', | ||
}; | ||
|
||
await Parse.User.logInWith('facebook', { authData: socialAuthData }); | ||
|
||
expect(config.verifyUserEmails).toHaveBeenCalledWith({ | ||
action: 'login', | ||
authProvider: 'facebook', | ||
}); | ||
}); | ||
}); | ||
|
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.