Skip to content

Don't trigger beforeSave on login #623

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
wants to merge 1 commit into from
Closed

Don't trigger beforeSave on login #623

wants to merge 1 commit into from

Conversation

simonbengtsson
Copy link
Contributor

The Parse iOS SDK (and maybe others?) sends a "create user request" even though the user already exists. Basically using a create request to login. It is handled in parse-server right now by short circuiting the request:

// RestWrite.js::321
if (!this.query) {
  // We're signing up, but this user already exists. Short-circuit
  delete results[0].password;
  this.response = {
    response: results[0],
    location: this.location()
  };
  return;
}

The problem is that this check happens after the beforeSave is triggered which means it will be triggered for every login. This PR fixes that and short circuits before the beforeSave is called.

One side effect of this PR is that the beforeSave is not triggered when authData, username or password is invalid. I thought this made sense, but it might be up for discussion.

This PR brings parse-server closer to parse.com as beforeSave was not called on login there.

@nlutsenko
Copy link
Contributor

Looks it needs some rebasing, but I agree with restoring the proper intention of not using triggering beforeSave on user login.
Can we also add few tests here?

@simonbengtsson
Copy link
Contributor Author

With the latest updates I am not seeing this anymore and beforeSave is not called on login.

@nlutsenko
Copy link
Contributor

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants