parse-community / parse-community/parse-server

`authData` is reset on save for newly created anonymous user

Open
#7,401 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
JavaScript
Stars
21.4k
Forks
4.8k
Avg merge
7h 45m
Merged PRs (30d)
11

Description

New Issue Checklist
Issue Description

authData is reset for newly created anonymous users, if I just save it right after creating.

Steps to reproduce

To reproduce the issue use this cloud code. It's minimal artificial example, but it shows the problem:

const user = await Parse.AnonymousUtils.logIn()
await user.save(null, { useMasterKey: true })

But there is workaround to keep authData in place:

const user = await Parse.AnonymousUtils.logIn()
await user.save('authData', {}, { useMasterKey: true })

in this case it's not overwritten by empty object, and keeps original value.

Actual Outcome

authData should be saved to DB

Expected Outcome

authData is undefined in DB

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: OS X Bug Sur 11.2.1
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local and remote Heroku

Database

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

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): JavaScript
  • SDK version: 2.17.0
Logs

no logs

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with Parse.AnonymousUtils.logIn followed by user.save(null, { useMasterKey: true }), then compare it with the workaround that explicitly saves authData. Trace how the Parse Server save path handles authData for newly created anonymous users; done means the original authData remains persisted after the immediate save.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, node.js
Domain
authentication, backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.