diff --git a/kernel/classes/datatypes/ezuser/ezusertype.php b/kernel/classes/datatypes/ezuser/ezusertype.php index 2e336712547..485c32d404a 100644 --- a/kernel/classes/datatypes/ezuser/ezusertype.php +++ b/kernel/classes/datatypes/ezuser/ezusertype.php @@ -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( diff --git a/kernel/user/ezuseroperationcollection.php b/kernel/user/ezuseroperationcollection.php index 4b657dd7d96..55c0a1a9324 100644 --- a/kernel/user/ezuseroperationcollection.php +++ b/kernel/user/ezuseroperationcollection.php @@ -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 @@ -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 *