Skip to content

User.linkWith doesn't remove anonymous auth #1353

Closed
@swittk

Description

@swittk

New Issue Checklist

Issue Description

Calling user.linkWith() server-side doesn't remove the "anonymous" field from the authData object field, causing Parse.AnonymousUtils to still report the user as an Anonymous user.

Steps to reproduce

Parse.Cloud.define('linkWithAccount', async (request) => {
  const user = request.user;
  if (!user) throw 'NoUser';
  const provider = request.params.provider as string;
  const authData = request.params.authData as any;
  if (!provider) throw 'NoProvider';
  else if (!authData) throw 'NoAuthData';

  await user.linkWith(provider, { authData }, {
    useMasterKey: true,
    sessionToken: user.getSessionToken()
  });
  
  return { ok: true };
});

Actual Outcome

The authData field on Parse Database still has the "anonymous" field, resulting in Parse.AnonymousUtils to still report the user as an Anonymous user

{
  "anonymous": {
    "id": "<random-string>"
  },
  "<linked_service_name>": {
    ...linked_service_data
  }
}

Expected Outcome

Inpecting the authData field on Parse Database not have the anonymous field (should only have..)

{
  "<linked_service_name>": {
    ...linked_service_data
  }
}

Failing Test Case / Pull Request

  • 🤩 I submitted a PR with a fix and a test case.
  • 🧐 I submitted a PR with a failing test case.

Environment

Server

  • Parse Server version: 4.5.0
  • Operating system: Mac OS X Mojave 10.14.6
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): Heroku

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: FILL_THIS_OUT
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): MongoDB Atlas

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): Javascript (React-Native)
  • SDK version: 2.19.0

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions