@@ -853,7 +853,7 @@ RestWrite.prototype._validatePasswordRequirements = function () {
853
853
}
854
854
if ( this . data . password . indexOf ( results [ 0 ] . username ) >= 0 )
855
855
{ return Promise . reject (
856
- new Parse . Error ( Parse . Error . VALIDATION_ERROR , containsUsernameError )
856
+ new Parse . Error ( Parse . Error . VALIDATION_ERROR , containsUsernameError )
857
857
) ; }
858
858
return Promise . resolve ( ) ;
859
859
} ) ;
@@ -880,16 +880,16 @@ RestWrite.prototype._validatePasswordHistory = function () {
880
880
let oldPasswords = [ ] ;
881
881
if ( user . _password_history )
882
882
{ oldPasswords = _ . take (
883
- user . _password_history ,
884
- this . config . passwordPolicy . maxPasswordHistory - 1
883
+ user . _password_history ,
884
+ this . config . passwordPolicy . maxPasswordHistory - 1
885
885
) ; }
886
886
oldPasswords . push ( user . password ) ;
887
887
const newPassword = this . data . password ;
888
888
// compare the new password hash with all old password hashes
889
889
const promises = oldPasswords . map ( function ( hash ) {
890
890
return passwordCrypto . compare ( newPassword , hash ) . then ( result => {
891
891
if ( result )
892
- // reject if there is a match
892
+ // reject if there is a match
893
893
{ return Promise . reject ( 'REPEAT_PASSWORD' ) ; }
894
894
return Promise . resolve ( ) ;
895
895
} ) ;
@@ -901,12 +901,12 @@ RestWrite.prototype._validatePasswordHistory = function () {
901
901
} )
902
902
. catch ( err => {
903
903
if ( err === 'REPEAT_PASSWORD' )
904
- // a match was found
904
+ // a match was found
905
905
{ return Promise . reject (
906
- new Parse . Error (
907
- Parse . Error . VALIDATION_ERROR ,
908
- `New password should not be the same as last ${ this . config . passwordPolicy . maxPasswordHistory } passwords.`
909
- )
906
+ new Parse . Error (
907
+ Parse . Error . VALIDATION_ERROR ,
908
+ `New password should not be the same as last ${ this . config . passwordPolicy . maxPasswordHistory } passwords.`
909
+ )
910
910
) ; }
911
911
throw err ;
912
912
} ) ;
@@ -1436,6 +1436,18 @@ RestWrite.prototype.runDatabaseOperation = function () {
1436
1436
`Cannot modify user ${ this . query . objectId } .`
1437
1437
) ;
1438
1438
}
1439
+ // Handle authData updates for _User class
1440
+ if ( this . className === '_User' && this . query && this . data . authData ) {
1441
+ if ( ! this . auth . isMaster && ! this . auth . isMaintenance ) {
1442
+ // For non-master key requests, remove authData from the update
1443
+ delete this . data . authData ;
1444
+ // If no other fields to update, return early
1445
+ if ( Object . keys ( this . data ) . length === 0 ) {
1446
+ this . response = { response : { } } ;
1447
+ return Promise . resolve ( ) ;
1448
+ }
1449
+ }
1450
+ }
1439
1451
1440
1452
if ( this . className === '_Product' && this . data . download ) {
1441
1453
this . data . downloadName = this . data . download . name ;
0 commit comments