MCPcopy Index your code
hub / github.com/parse-community/parse-server / applyAuthDataOptimisticLock

Function applyAuthDataOptimisticLock

src/AuthDataLock.js:15–33  ·  view source on GitHub ↗
(query, originalAuthData, newAuthData)

Source from the content-addressed store, hash-verified

13// recovery-code array) is sufficient — its removal invalidates the WHERE clause
14// for concurrent writers.
15export function applyAuthDataOptimisticLock(query, originalAuthData, newAuthData) {
16 if (!originalAuthData) {
17 return;
18 }
19 for (const provider of Object.keys(newAuthData)) {
20 const original = originalAuthData[provider];
21 if (!original || typeof original !== 'object') {
22 continue;
23 }
24 for (const [field, value] of Object.entries(original)) {
25 if (!isLockableAuthDataValue(value)) {
26 continue;
27 }
28 if (JSON.stringify(value) !== JSON.stringify(newAuthData[provider]?.[field])) {
29 query[`authData.${provider}.${field}`] = value;
30 }
31 }
32 }
33}
34
35function isLockableAuthDataValue(value) {
36 if (value === null || value === undefined) {

Callers 2

RestWrite.jsFile · 0.90
handleLogInMethod · 0.90

Calls 1

isLockableAuthDataValueFunction · 0.85

Tested by

no test coverage detected