Source of file UserUpdatePassword.php

Size: 1,319 Bytes - Last Modified: 2018-11-03T09:50:48-04:00

G:/AdobeConnectClient/src/Commands/UserUpdatePassword.php

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
<?php

namespace AdobeConnectClient\Commands;

use AdobeConnectClient\Command;
use AdobeConnectClient\Converter\Converter;
use AdobeConnectClient\Helpers\StatusValidate;

/**
 * Changes user’s password.
 *
 * More info see {@link https://helpx.adobe.com/adobe-connect/webservices/user-update-pwd.html}
 */
class UserUpdatePassword extends Command
{
    /**
     * @var array
     */
    protected $parameters;

    /**
     * @param int $userId The Principal Id for user
     * @param string $newPassword
     * @param string $oldPassword
     */
    public function __construct($userId, $newPassword, $oldPassword = '')
    {
        $this->parameters = [
            'action' => 'user-update-pwd',
            'password' => $newPassword,
            'user-id' => (int) $userId,
            'password-verify' => $newPassword,
        ];

        if (!empty($oldPassword)) {
            $this->parameters['password-old'] = $oldPassword;
        }
    }

    /**
     * @inheritdoc
     *
     * @return bool
     */
    protected function process()
    {
        $response = Converter::convert(
            $this->client->doGet(
                $this->parameters + ['session' => $this->client->getSession()]
            )
        );
        StatusValidate::validate($response['status']);
        return true;
    }
}