Skip to content

Arguments missing or incorrect in verifyUserEmails on verificationEmailRequest #8874

Closed
@mtrezza

Description

@mtrezza

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:breakingBreaking change requires major version increment and `BREAKING CHANGE` commit messagetype:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions