Skip to content
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

test: Add test for email verification not applying to auth sign-up #8740

Open
wants to merge 25 commits into
base: alpha
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift click to select a range
34dc306
Added test for Facebook signup, login using await/async as first ste…
ashish-naik Sep 5, 2023
11d2a1f
Added test in ParseUser.spec.js for testing Facebook sign up followed…
ashish-naik Sep 6, 2023
fafd04f
Merge branch 'parse-community:alpha' into Facebook-signup-error206
ashish-naik Sep 6, 2023
ab72478
Update spec/ParseUser.spec.js
ashish-naik Sep 7, 2023
d5474d3
Doing reconfigure server with email adaptor options used in index.js.…
ashish-naik Sep 7, 2023
3d6b9c4
Kept only code that is failing the test. Renamed test.
ashish-naik Sep 8, 2023
8f11478
Updated test to use ExpectAsync and removed done()
ashish-naik Sep 8, 2023
46f8e10
Update spec/ParseUser.spec.js
mtrezza Sep 8, 2023
af1616c
Update spec/ParseUser.spec.js
mtrezza Sep 8, 2023
8e818c0
Update spec/ParseUser.spec.js
mtrezza Sep 8, 2023
def6bff
Update spec/ParseUser.spec.js
mtrezza Sep 8, 2023
b1e1bf6
Merge branch 'alpha' into Facebook-signup-error206
mtrezza Sep 16, 2023
fae2b44
authProvider is not set currently during auth sign up. Setting storag…
ashish-naik Sep 17, 2023
e01c9f5
authProvider is not set currently during auth sign up. Setting storag…
ashish-naik Sep 17, 2023
a945431
Committing changes done for testing.
ashish-naik Sep 19, 2023
dd5529c
Merge commit 'b1e1bf6708f5d32b2846e66de40f48fb0ec1dc86' into alpha
ashish-naik Sep 19, 2023
e118629
Merge branch 'alpha' into Facebook-signup-error206
ashish-naik Nov 26, 2023
7775f14
Merge branch 'alpha' into Facebook-signup-error206
mtrezza Mar 21, 2024
d3d0f7d
Merge branch 'parse-community:alpha' into alpha
ashish-naik May 5, 2024
c2063f5
Merge branch 'alpha' of https://github.com/ashish-naik/parse-server-F…
ashish-naik May 5, 2024
b78e784
Reproducing error using test
ashish-naik May 5, 2024
cf1b227
review
mtrezza May 5, 2024
5937c91
Added test to ParseUser.spec.js
ashish-naik May 12, 2024
266abe0
Update RestWrite.js for solution of Auth error
ashish-naik May 13, 2024
93485f2
Update ParseUser.spec.js - updated test
ashish-naik May 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions spec/ParseUser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 1262,29 @@ describe('Parse.User testing', () => {
done();
});

fit('log in with Facebook and save signed up User with verifyUserEmails=true and preventLoginWithUnverifiedEmail=true', async () => {
const provider = getMockFacebookProvider();
const emailAdapter = {
sendPasswordResetEmail: () => Promise.resolve(),
sendMail: () => Promise.resolve(),
};
await reconfigureServer({
appName: 'ExampleApp',
verifyUserEmails: true,
preventLoginWithUnverifiedEmail: true,
emailAdapter: {
module: emailAdapter,
},
publicServerURL: 'http://localhost:8378/1',
ashish-naik marked this conversation as resolved.
Show resolved Hide resolved
});

Parse.User._registerAuthenticationProvider(provider);
const user = await Parse.User.logInWith('facebook', {authData: provider.authData});
expect(user.getSessionToken()).toBeDefined()
user.save()
await expectAsync(user.save()).toBeResolved();
});

it('can not set authdata to null', async () => {
try {
const provider = getMockFacebookProvider();
Expand Down
3 changes: 2 additions & 1 deletion src/RestWrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 527,8 @@ RestWrite.prototype.handleAuthData = async function (authData) {
const userResult = results[0];
const foundUserIsNotCurrentUser = userId && userResult && userId !== userResult.objectId;

this.storage.authProvider = Object.keys(authData).join(',');

if (results.length > 1 || foundUserIsNotCurrentUser) {
// To avoid https://github.com/parse-community/parse-server/security/advisories/GHSA-8w3j-g983-8jh5
// Let's run some validation before throwing
Expand All @@ -548,7 550,6 @@ RestWrite.prototype.handleAuthData = async function (authData) {

// User found with provided authData
if (results.length === 1) {

this.storage.authProvider = Object.keys(authData).join(',');

const { hasMutatedAuthData, mutatedAuthData } = Auth.hasMutatedAuthData(
Expand Down