@@ -1161,7 +1161,7 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor
11611161 throw new Exception (Exception::USER_NOT_FOUND );
11621162 }
11631163
1164- $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), $ user -> setAttribute ( 'status ' , (bool ) $ status ));
1164+ $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), new Document ([ 'status ' => (bool ) $ status] ));
11651165
11661166 $ queueForEvents
11671167 ->setParam ('userId ' , $ user ->getId ());
@@ -1204,7 +1204,7 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor
12041204
12051205 $ user ->setAttribute ('labels ' , (array ) \array_values (\array_unique ($ labels )));
12061206
1207- $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), $ user );
1207+ $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), new Document ([ ' labels ' => $ user-> getAttribute ( ' labels ' )]) );
12081208
12091209 $ queueForEvents
12101210 ->setParam ('userId ' , $ user ->getId ());
@@ -1245,7 +1245,7 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor
12451245 throw new Exception (Exception::USER_NOT_FOUND );
12461246 }
12471247
1248- $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), $ user -> setAttribute ( 'phoneVerification ' , $ phoneVerification ));
1248+ $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), new Document ([ 'phoneVerification ' => $ phoneVerification] ));
12491249
12501250 $ queueForEvents
12511251 ->setParam ('userId ' , $ user ->getId ());
@@ -1289,7 +1289,7 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor
12891289
12901290 $ user ->setAttribute ('name ' , $ name );
12911291
1292- $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), $ user );
1292+ $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), new Document ([ ' name ' => $ user-> getAttribute ( ' name ' )]) );
12931293
12941294 $ queueForEvents ->setParam ('userId ' , $ user ->getId ());
12951295
@@ -1344,7 +1344,10 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor
13441344 ->setAttribute ('password ' , '' )
13451345 ->setAttribute ('passwordUpdate ' , DateTime::now ());
13461346
1347- $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), $ user );
1347+ $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), new Document ([
1348+ 'password ' => $ user ->getAttribute ('password ' ),
1349+ 'passwordUpdate ' => $ user ->getAttribute ('passwordUpdate ' ),
1350+ ]));
13481351 $ queueForEvents ->setParam ('userId ' , $ user ->getId ());
13491352 $ response ->dynamic ($ user , Response::MODEL_USER );
13501353 }
@@ -1377,7 +1380,13 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor
13771380 ->setAttribute ('hash ' , $ hasher ->getName ())
13781381 ->setAttribute ('hashOptions ' , $ hasher ->getOptions ());
13791382
1380- $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), $ user );
1383+ $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), new Document ([
1384+ 'password ' => $ user ->getAttribute ('password ' ),
1385+ 'passwordHistory ' => $ user ->getAttribute ('passwordHistory ' ),
1386+ 'passwordUpdate ' => $ user ->getAttribute ('passwordUpdate ' ),
1387+ 'hash ' => $ user ->getAttribute ('hash ' ),
1388+ 'hashOptions ' => $ user ->getAttribute ('hashOptions ' ),
1389+ ]));
13811390
13821391 $ sessions = $ user ->getAttribute ('sessions ' , []);
13831392 $ invalidate = $ project ->getAttribute ('auths ' , default: [])['invalidateSessions ' ] ?? false ;
@@ -1469,15 +1478,23 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor
14691478 ;
14701479
14711480 try {
1472- $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), $ user );
1481+ $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), new Document ([
1482+ 'email ' => $ user ->getAttribute ('email ' ),
1483+ 'emailVerification ' => $ user ->getAttribute ('emailVerification ' ),
1484+ 'emailCanonical ' => $ user ->getAttribute ('emailCanonical ' ),
1485+ 'emailIsCanonical ' => $ user ->getAttribute ('emailIsCanonical ' ),
1486+ 'emailIsCorporate ' => $ user ->getAttribute ('emailIsCorporate ' ),
1487+ 'emailIsDisposable ' => $ user ->getAttribute ('emailIsDisposable ' ),
1488+ 'emailIsFree ' => $ user ->getAttribute ('emailIsFree ' ),
1489+ ]));
14731490 /**
14741491 * @var Document $oldTarget
14751492 */
14761493 $ oldTarget = $ user ->find ('identifier ' , $ oldEmail , 'targets ' );
14771494
14781495 if ($ oldTarget instanceof Document && !$ oldTarget ->isEmpty ()) {
14791496 if (\strlen ($ email ) !== 0 ) {
1480- $ dbForProject ->updateDocument ('targets ' , $ oldTarget ->getId (), $ oldTarget -> setAttribute ( 'identifier ' , $ email ));
1497+ $ dbForProject ->updateDocument ('targets ' , $ oldTarget ->getId (), new Document ([ 'identifier ' => $ email] ));
14811498 } else {
14821499 $ dbForProject ->deleteDocument ('targets ' , $ oldTarget ->getId ());
14831500 }
@@ -1558,15 +1575,18 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor
15581575 }
15591576
15601577 try {
1561- $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), $ user );
1578+ $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), new Document ([
1579+ 'phone ' => $ user ->getAttribute ('phone ' ),
1580+ 'phoneVerification ' => $ user ->getAttribute ('phoneVerification ' ),
1581+ ]));
15621582 /**
15631583 * @var Document $oldTarget
15641584 */
15651585 $ oldTarget = $ user ->find ('identifier ' , $ oldPhone , 'targets ' );
15661586
15671587 if ($ oldTarget instanceof Document && !$ oldTarget ->isEmpty ()) {
15681588 if (\strlen ($ number ) !== 0 ) {
1569- $ dbForProject ->updateDocument ('targets ' , $ oldTarget ->getId (), $ oldTarget -> setAttribute ( 'identifier ' , $ number ));
1589+ $ dbForProject ->updateDocument ('targets ' , $ oldTarget ->getId (), new Document ([ 'identifier ' => $ number] ));
15701590 } else {
15711591 $ dbForProject ->deleteDocument ('targets ' , $ oldTarget ->getId ());
15721592 }
@@ -1630,7 +1650,7 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor
16301650 throw new Exception (Exception::USER_NOT_FOUND );
16311651 }
16321652
1633- $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), $ user -> setAttribute ( 'emailVerification ' , $ emailVerification ));
1653+ $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), new Document ([ 'emailVerification ' => $ emailVerification] ));
16341654
16351655 $ queueForEvents ->setParam ('userId ' , $ user ->getId ());
16361656
@@ -1668,7 +1688,7 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor
16681688 throw new Exception (Exception::USER_NOT_FOUND );
16691689 }
16701690
1671- $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), $ user -> setAttribute ( 'prefs ' , $ prefs ));
1691+ $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), new Document ([ 'prefs ' => $ prefs] ));
16721692
16731693 $ queueForEvents
16741694 ->setParam ('userId ' , $ user ->getId ());
@@ -1768,7 +1788,13 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor
17681788 $ target ->setAttribute ('name ' , $ name );
17691789 }
17701790
1771- $ target = $ dbForProject ->updateDocument ('targets ' , $ target ->getId (), $ target );
1791+ $ target = $ dbForProject ->updateDocument ('targets ' , $ target ->getId (), new Document ([
1792+ 'identifier ' => $ target ->getAttribute ('identifier ' ),
1793+ 'expired ' => $ target ->getAttribute ('expired ' ),
1794+ 'providerId ' => $ target ->getAttribute ('providerId ' ),
1795+ 'providerInternalId ' => $ target ->getAttribute ('providerInternalId ' ),
1796+ 'name ' => $ target ->getAttribute ('name ' ),
1797+ ]));
17721798 $ dbForProject ->purgeCachedDocument ('users ' , $ user ->getId ());
17731799
17741800 $ queueForEvents
@@ -1836,7 +1862,7 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor
18361862
18371863 $ user ->setAttribute ('mfa ' , $ mfa );
18381864
1839- $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), $ user );
1865+ $ user = $ dbForProject ->updateDocument ('users ' , $ user ->getId (), new Document ([ ' mfa ' => $ user-> getAttribute ( ' mfa ' )]) );
18401866
18411867 $ queueForEvents ->setParam ('userId ' , $ user ->getId ());
18421868
@@ -2024,7 +2050,7 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor
20242050
20252051 $ mfaRecoveryCodes = Type::generateBackupCodes ();
20262052 $ user ->setAttribute ('mfaRecoveryCodes ' , $ mfaRecoveryCodes );
2027- $ dbForProject ->updateDocument ('users ' , $ user ->getId (), $ user );
2053+ $ dbForProject ->updateDocument ('users ' , $ user ->getId (), new Document ([ ' mfaRecoveryCodes ' => $ mfaRecoveryCodes ]) );
20282054
20292055 $ queueForEvents ->setParam ('userId ' , $ user ->getId ());
20302056
@@ -2096,7 +2122,7 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor
20962122
20972123 $ mfaRecoveryCodes = Type::generateBackupCodes ();
20982124 $ user ->setAttribute ('mfaRecoveryCodes ' , $ mfaRecoveryCodes );
2099- $ dbForProject ->updateDocument ('users ' , $ user ->getId (), $ user );
2125+ $ dbForProject ->updateDocument ('users ' , $ user ->getId (), new Document ([ ' mfaRecoveryCodes ' => $ mfaRecoveryCodes ]) );
21002126
21012127 $ queueForEvents ->setParam ('userId ' , $ user ->getId ());
21022128
0 commit comments