parse-community / parse-server

Parse Server for Node.js / Express
https://parseplatform.org
Apache License 2.0
20.83k stars 4.77k forks source link

The `_hashed_password` field cannot be deleted from _User collection #9287

Open tiavina-mika opened 3 weeks ago

tiavina-mika commented 3 weeks ago

New Issue Checklist

Issue Description

The _hashed_password field cannot be deleted from _User collection

Steps to reproduce

I try

user.unset('_hashed_password')

Actual Outcome

The field is not deleted in the _User collection

Expected Outcome

_hashed_password field should be deleted in the _User collection

Environment

Server

Database

Client

parse-github-assistant[bot] commented 3 weeks ago

Thanks for opening this issue!

tiavina-mika commented 3 weeks ago

The solution I found is to delete it using mongodb directly

import Config from 'parse-server/lib/Config';

const user = await new Parse.Query(Parse.User).equalTo('objectId', 'xxxxx').first({ useMasterKey: true });
const config = Config.get(Parse.applicationId);
const mongoAdapter = config.database.adapter;
await mongoAdapter.connect();
const userCollection = mongoAdapter.database.collection('_User');
const query = { _id: user.id };
const body = { $unset: { "_hashed_password": "" } };
await userCollection.updateOne(query, body);