Skip to content

Commit b0adf7e

Browse files
authored
feat: Add password validation for user with unverified email via Parse.User.verifyPassword using master key and option ignoreEmailVerification: true (#2076)
1 parent f56b9ed commit b0adf7e

File tree

7 files changed

+118
-228
lines changed

7 files changed

+118
-228
lines changed

integration/test/ParseUserTest.js

+13
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,19 @@ describe('Parse User', () => {
10571057
}
10581058
});
10591059

1060+
it('can verify user password for user with unverified email', async () => {
1061+
await reconfigureServer({
1062+
appName: 'AppName',
1063+
publicServerURL: 'http://localhost:1337/',
1064+
verifyUserEmails: true,
1065+
preventLoginWithUnverifiedEmail: true,
1066+
});
1067+
await Parse.User.signUp('asd123', 'xyz123');
1068+
const res = await Parse.User.verifyPassword('asd123', 'xyz123', { useMasterKey: true, ignoreEmailVerification: true });
1069+
expect(typeof res).toBe('object');
1070+
expect(res.username).toBe('asd123');
1071+
});
1072+
10601073
it('can encrypt user', async () => {
10611074
Parse.User.enableUnsafeCurrentUser();
10621075
Parse.enableEncryptedUser();

integration/test/helper.js

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const Parse = require('../../node');
1111
const fs = require('fs');
1212
const path = require('path');
1313
const dns = require('dns');
14+
const MockEmailAdapterWithOptions = require('./support/MockEmailAdapterWithOptions');
1415

1516
// Ensure localhost resolves to ipv4 address first on node v17+
1617
if (dns.setDefaultResultOrder) {
@@ -83,6 +84,11 @@ const defaultConfiguration = {
8384
revokeSessionOnPasswordReset: false,
8485
allowCustomObjectId: false,
8586
allowClientClassCreation: true,
87+
emailAdapter: MockEmailAdapterWithOptions({
88+
fromAddress: '[email protected]',
89+
apiKey: 'k',
90+
domain: 'd',
91+
}),
8692
};
8793

8894
const openConnections = {};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = options => {
2+
if (!options) {
3+
throw 'Options were not provided';
4+
}
5+
const adapter = {
6+
sendVerificationEmail: () => Promise.resolve(),
7+
sendPasswordResetEmail: () => Promise.resolve(),
8+
sendMail: () => Promise.resolve(),
9+
};
10+
if (options.sendMail) {
11+
adapter.sendMail = options.sendMail;
12+
}
13+
if (options.sendPasswordResetEmail) {
14+
adapter.sendPasswordResetEmail = options.sendPasswordResetEmail;
15+
}
16+
if (options.sendVerificationEmail) {
17+
adapter.sendVerificationEmail = options.sendVerificationEmail;
18+
}
19+
20+
return adapter;
21+
};

0 commit comments

Comments
 (0)