Skip to content

Commit

Permalink
Fix EZP-30383: Change password with "legacy_mode: false" does not pro…
Browse files Browse the repository at this point in the history
…perly clear the cache (ezsystems#139)
  • Loading branch information
pkamps authored Apr 2, 2019
1 parent f59b0dd commit fc5a970
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/classes/datatypes/ezuser/ezusertype.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ function onPublish( $contentObjectAttribute, $contentObject, $publishedNodes )
* @param eZUser $user
* @return string
*/
private function serializeDraft( eZUser $user )
public static function serializeDraft( eZUser $user )
{
return json_encode(
array(
Expand Down
26 changes: 26 additions & 0 deletions kernel/user/ezuseroperationcollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ static public function password( $userID, $newPassword )
$user->setAttribute( 'password_hash', $newHash );
$user->setAttribute( 'password_hash_type', $type );
$user->store();

// "Draft" must be in sync with the PersistentObject
self::updateUserDraft( $user );

eZContentCacheManager::clearContentCacheIfNeeded( $userID );

return array( 'status' => true );
}
else
Expand All @@ -326,6 +332,26 @@ static public function password( $userID, $newPassword )
}
}

/**
* Update the "draft" of a given user
*
* @param $user eZUser
*/
static private function updateUserDraft( $user )
{
$userObject = eZContentObject::fetch( $user->id() );

foreach ( $userObject->dataMap() as $attribute )
{
if ( $attribute->ContentClassAttributeIdentifier == 'user_account' )
{
$attribute->setAttribute( 'data_text', eZUserType::serializeDraft( $user ) );
$attribute->store();
break;
}
}
}

/**
* Generate forgotpassword object
*
Expand Down

0 comments on commit fc5a970

Please sign in to comment.