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

feat: Add password validation for user with unverified email via Parse.User.verifyPassword using master key and option ignoreEmailVerification: true #2076

Merged
13 changes: 13 additions & 0 deletions integration/test/ParseUserTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,19 @@ describe('Parse User', () => {
}
});

it('can verify user password for user with unverified email', async () => {
await reconfigureServer({
appName: 'AppName',
publicServerURL: 'http://localhost:1337/',
verifyUserEmails: true,
preventLoginWithUnverifiedEmail: true,
});
await Parse.User.signUp('asd123', 'xyz123');
const res = await Parse.User.verifyPassword('asd123', 'xyz123', { useMasterKey: true, ignoreEmailVerification: true });
expect(typeof res).toBe('object');
expect(res.username).toBe('asd123');
});

it('can encrypt user', async () => {
Parse.User.enableUnsafeCurrentUser();
Parse.enableEncryptedUser();
Expand Down
6 changes: 6 additions & 0 deletions integration/test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const Parse = require('../../node');
const fs = require('fs');
const path = require('path');
const dns = require('dns');
const MockEmailAdapterWithOptions = require('./support/MockEmailAdapterWithOptions');

// Ensure localhost resolves to ipv4 address first on node v17+
if (dns.setDefaultResultOrder) {
Expand Down Expand Up @@ -83,6 +84,11 @@ const defaultConfiguration = {
revokeSessionOnPasswordReset: false,
allowCustomObjectId: false,
allowClientClassCreation: true,
emailAdapter: MockEmailAdapterWithOptions({
fromAddress: 'parse@example.com',
apiKey: 'k',
domain: 'd',
}),
};

const openConnections = {};
Expand Down
21 changes: 21 additions & 0 deletions integration/test/support/MockEmailAdapterWithOptions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = options => {
if (!options) {
throw 'Options were not provided';
}
const adapter = {
sendVerificationEmail: () => Promise.resolve(),
sendPasswordResetEmail: () => Promise.resolve(),
sendMail: () => Promise.resolve(),
};
if (options.sendMail) {
adapter.sendMail = options.sendMail;
}
if (options.sendPasswordResetEmail) {
adapter.sendPasswordResetEmail = options.sendPasswordResetEmail;
}
if (options.sendVerificationEmail) {
adapter.sendVerificationEmail = options.sendVerificationEmail;
}

return adapter;
};
Loading
Loading