Skip to content

Commit 90f170a

Browse files
committed
Properly deletes authData.provider when set to null
1 parent 40812e2 commit 90f170a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/transform.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function transformKeyValue(schema, className, restKey, restValue, options
8787
return transformWhere(schema, className, s);
8888
});
8989
return {key: '$and', value: mongoSubqueries};
90-
default:
90+
default:
9191
// Other auth data
9292
var authDataMatch = key.match(/^authData\.([a-zA-Z0-9_]+)\.id$/);
9393
if (authDataMatch) {
@@ -224,7 +224,7 @@ function transformUpdate(schema, className, restUpdate) {
224224
if (className == '_User') {
225225
restUpdate = transformAuthData(restUpdate);
226226
}
227-
227+
228228
var mongoUpdate = {};
229229
var acl = transformACL(restUpdate);
230230
if (acl._rperm || acl._wperm) {
@@ -260,7 +260,14 @@ function transformUpdate(schema, className, restUpdate) {
260260
function transformAuthData(restObject) {
261261
if (restObject.authData) {
262262
Object.keys(restObject.authData).forEach((provider) => {
263-
restObject[`_auth_data_${provider}`] = restObject.authData[provider];
263+
let providerData = restObject.authData[provider];
264+
if (providerData == null) {
265+
restObject[`_auth_data_${provider}`] = {
266+
__op: 'Delete'
267+
}
268+
} else {
269+
restObject[`_auth_data_${provider}`] = providerData;
270+
}
264271
});
265272
delete restObject.authData;
266273
}
@@ -823,4 +830,3 @@ module.exports = {
823830
transformWhere: transformWhere,
824831
untransformObject: untransformObject
825832
};
826-

0 commit comments

Comments
 (0)