Skip to content

Arguments missing or incorrect in verifyUserEmails on verificationEmailRequest #8874

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

Closed
4 tasks done
mtrezza opened this issue Jan 6, 2024 · 1 comment · Fixed by #8873
Closed
4 tasks done

Arguments missing or incorrect in verifyUserEmails on verificationEmailRequest #8874

mtrezza opened this issue Jan 6, 2024 · 1 comment · Fixed by #8873
Labels
state:breaking Breaking change requires major version increment and `BREAKING CHANGE` commit message type:feature New feature or improvement of existing feature

Comments

@mtrezza
Copy link
Member

mtrezza commented Jan 6, 2024

New Issue Checklist

Issue Description

There are several issues if the Parse Server option verifyUserEmails is set to a function and the email verification email is re-requested via the verificationEmailRequest REST endpoint or via Parse.User.requestEmailVerification:

  • The Parse.User argument in verifyUserEmails is called user, but in all other cases it is called object.
  • The Parse.User argument in verifyUserEmails is a plain JS object, not a Parse.User object as in all other cases.
  • The IP address is not passed as argument.
  • The installation ID is not passed as argument.

In addition, it cannot be determined whether the verifyUserEmails is called due to a signup or login, or because the verification email is manually re-requested. Therefore it's not easily possible to limit the frequency with which a user can re-request verification emails.

Steps to reproduce

const user = new Parse.User();
user.setUsername('user');
user.setPassword('pass');
user.set('email', '[email protected]');
await user.signUp();

const verifyUserEmails = {
  method: async (params) => {
    expect(params.object).toBeInstanceOf(Parse.User);
    expect(params.ip).toBeDefined();
    expect(params.master).toBeDefined();
    expect(params.installationId).toBeDefined();
    expect(params.resendRequest).toBeTrue();
    return true;
  },
};
const verifyUserEmailsSpy = spyOn(verifyUserEmails, 'method').and.callThrough();
await reconfigureServer({
  appName: 'test',
  publicServerURL: 'http://localhost:1337/1',
  verifyUserEmails: verifyUserEmails.method,
  preventLoginWithUnverifiedEmail: verifyUserEmails.method,
  preventSignupWithUnverifiedEmail: true,
  emailAdapter: MockEmailAdapterWithOptions({
    fromAddress: '[email protected]',
    apiKey: 'k',
    domain: 'd',
  }),
});

await expectAsync(Parse.User.requestEmailVerification('[email protected]')).toBeResolved();
expect(verifyUserEmailsSpy).toHaveBeenCalledTimes(1);

Actual Outcome

Test fails.

Expected Outcome

Test should pass.

Environment

Server

  • Parse Server version: [7.0.0-alpha.4](https://github.com/parse-community/parse-server/releases/tag/7.0.0-alpha.4)
Copy link

parse-github-assistant bot commented Jan 6, 2024

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@mtrezza mtrezza added type:feature New feature or improvement of existing feature state:breaking Breaking change requires major version increment and `BREAKING CHANGE` commit message labels Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:breaking Breaking change requires major version increment and `BREAKING CHANGE` commit message type:feature New feature or improvement of existing feature
Projects
None yet
1 participant