Change email account password

@param string $address  Email address/username
@param string $password Email account password

@return int|array Operation status
542256
function setPassword($address, $password)
    {
        if (strpos($address, '@')) {
            list($data['email'], $data['domain']) = explode('@', $address);
        }
        else {
            list($data['email'], $data['domain']) = array($address, '');
        }

        $data['password'] = $password;

        // Get the cPanel user
        $query = $this->xmlapi->listaccts('domain', $data['domain']);
        $query = json_decode($query, true);
        if ( $query['status'] != 1) {
            return false;
        }
        $cpanel_user = $query['acct'][0]['user'];

        $query  = $this->xmlapi->api2_query($cpanel_user, 'Email', 'passwdpop', $data);
        $query  = json_decode($query, true);
        $result = $query['cpanelresult']['data'][0];

        if ($result['result'] == 1) {
            return PASSWORD_SUCCESS;
        }

        if ($result['reason']) {
            return array(
                'code'    => PASSWORD_ERROR,
                'message' => $result['reason'],
            );
        }

        return PASSWORD_ERROR;
    }
963101
public static function changePasswordByCode($email, $code, $newPassword, $login = true)
    {
        if (empty($email)) {
            throw new BadRequestException("Missing required email for password reset confirmation.");
        }

        if (empty($newPassword)) {
            throw new BadRequestException("Missing new password for reset.");
        }

        if (empty($code) || 'y' == $code) {
            throw new BadRequestException("Invalid confirmation code.");
        }

        /** @var User $user */
        $user = User::whereEmail($email)->whereConfirmCode($code)->first();

        if (null === $user) {
            // bad code
            throw new NotFoundException("The supplied email and/or confirmation code were not found in the system.");
        } elseif ($user->isConfirmationExpired()) {
            throw new BadRequestException("Confirmation code expired.");
        }

        static::isAllowed($user);

        try {
            $user->confirm_code = 'y';
            $user->password = $newPassword;
            $user->save();
        } catch (\Exception $ex) {
            throw new InternalServerErrorException("Error processing password reset.\n{$ex->getMessage()}");
        }

        if ($login) {
            static::userLogin($email, $newPassword);

            return ['success' => true, 'session_token' => Session::getSessionToken()];
        }

        return ['success' => true];
    }
76058
public OvhTaskPop delegatedAccount_email_changePassword_POST(String email, String password) throws IOException {
		String qPath = "/email/domain/delegatedAccount/{email}/changePassword";
		StringBuilder sb = path(qPath, email);
		HashMap<String, Object>o = new HashMap<String, Object>();
		addBody(o, "password", password);
		String resp = exec(qPath, "POST", sb.toString(), o);
		return convertTo(resp, OvhTaskPop.class);
	}
1008244
public function setPassword($password)
        {
            if ($this->validatePassword($password) === false) {
                throw new Exception("Password \"$password\" is not a valid HTTP password.");
            }

            $oldPassword     = $this->_password;
            $this->_password = $password;

            return $oldPassword;
        }
354120
public function changePasswordAction()
    {
        $form = new ChangePasswordForm();

        if ($this->request->isPost()) {

            if (!$form->isValid($this->request->getPost())) {

                foreach ($form->getMessages() as $message) {
                    $this->flash->error($message);
                }
            } else {

                $user = $this->auth->getUser();

                $user->password = $this->security->hash($this->request->getPost('password'));
                $user->mustChangePassword = 'N';

                $passwordChange = new PasswordChanges();
                $passwordChange->user = $user;
                $passwordChange->ipAddress = $this->request->getClientAddress();
                $passwordChange->userAgent = $this->request->getUserAgent();

                if (!$passwordChange->save()) {
                    $this->flash->error($passwordChange->getMessages());
                } else {

                    $this->flash->success('Your password was successfully changed');

                    Tag::resetInput();
                }
            }
        }

        $this->view->form = $form;
    }
643632
public function resetPassword($password)
    {
        // Remove the activation token.
        $this->getPasswordResetToken()->delete();

        // Update the user table with the needed details.
        $this->password = $password;
        $this->trackTime('password_updated_at');
        $this->save();
    }
524487
public function setPassword($password = null)
    {
        if (empty($password)) {
            $passwordHash = '';
        } else {
            $passwordHash = $this->hashPassword($password);
        }

        $this->oxuser__oxpassword = new \OxidEsales\Eshop\Core\Field($passwordHash, \OxidEsales\Eshop\Core\Field::T_RAW);
        $this->oxuser__oxpasssalt = new \OxidEsales\Eshop\Core\Field('');
    }
1083471
public function changedPassword(array $user)
    {
        $store = $this->store->get($user['store_id']);
        $options = $this->store->getConfig(null, $store);
        $store_name = $this->store->getTranslation('title', $this->translation->getLangcode(), $store);

        $vars = array('@store' => $store_name, '@name' => $user['name']);
        $subject = $this->translation->text('Password has been changed for @name on @store', $vars);

        $message = $this->translation->text('Your password on @store has been changed', $vars);
        $message .= $this->getSignature($options);

        $options['from'] = $this->store->getConfig('email.0', $store);
        return array($user['email'], $subject, $message, $options);
    }
358355
public static function changePassword($username , $new_password)
	{
		self::setUser( $username , $new_password );
		self::log( 'changepwd' , $username );
		self::save();

		return true;
	}
987932
public function changePassword()
    {
        $user = $this->Users->get($this->Auth->user('id'));

        if ($this->request->is(['patch', 'post', 'put'])) {
            $user = $this->Users->patchEntity($user, $this->request->getData());

            if ($this->Users->save($user)) {
                //Sends email
                $this->getMailer('MeCms.User')->send('changePassword', [$user]);
                $this->Flash->success(I18N_OPERATION_OK);

                return $this->redirect(['_name' => 'dashboard']);
            }

            $this->Flash->error(I18N_OPERATION_NOT_OK);
        }

        $this->set(compact('user'));
    }
301969
protected function setPassword($password) {
        if (!isset($password)) $password = '';
        else if (!is_string($password)) throw new IllegalTypeException('Illegal type of parameter $password: '.gettype($password));

        $this->password = $password;
        return $this;
    }
138782
public function changePassword($email, $token, $password)
    {
        global $logger;
        $path     = 'users/password/change';
        $request = $this->_remoteServer->post($path)
            ->setPostField('email', $email)
            ->setPostField('token', $token)
            ->setPostField('password', $password);
        try {
            $response = $request->send();
        } catch(\Guzzle\Http\Exception\BadResponseException $e) {
            $logger->info($e->getResponse()->getBody('true'), array());
            return false;
        }
        return true; 

    }
131267
public function password($password = null) {
		while (empty($password)) {
			$password = $this->in('Password');
		}

		$this->loadModel(CLASS_USERS);
		$this->Users->addBehavior('Tools.Passwordable', ['confirm' => false]);

		/** @var \App\Model\Entity\User $entity */
		$entity = $this->Users->newEntity([
			'pwd' => $password,
		], ['validate' => false]);
		/** @var \Tools\Model\Behavior\PasswordableBehavior $Passwordable */
		$Passwordable = $this->Users->behaviors()->get('Passwordable');
		$Passwordable->beforeSave(new Event('beforeSave'), $entity, new ArrayObject());

		$this->out('Generating hash...');
		$this->hr();
		$this->out($entity->password);
		$this->hr();
	}
74386
public function actionChangePassword()
    {
        $model = new ChangePassword();
        if ($model->load(Yii::$app->getRequest()->post()) && $model->change()) {
            return $this->goHome();
        }

        return $this->render('change-password', [
                'model' => $model,
        ]);
    }
974309
public function updatePassword($token, $email, $password)
    {
        // Get the token being used.
        $token = $this->tokens->findByToken($token);

        // Make sure the correct email was supplied.
        if ($token->user->email !== $email) {
            return Response::failed('The email does not match this token.')
                           ->route('auth.password.reset');
        }

        // Reset the user's password and let them log in.
        $token->user->resetPassword($password);

        return Response::passed('Password updated.')
                       ->route('auth.login');
    }
832701
public function resetPassword(string $password) : void
    {
        if (empty($this->password_reset_token)) {
            throw new \DomainException(Yii::t('setrun/user', 'Password resetting is not requested'));
        }
        $this->setPassword($password);
        $this->removePasswordResetToken();
    }
189630
public function authenticateUser($email, $password) 
    {
        if (empty($this->config->getBearer())) {
            $this->getAccessToken();
        }
        // @todo validate email address and password
        $options = $this->config->getUserAuthenticationConfiguration(
            $email,
            $password
        );
        // @todo test, returns the bearer if success
        $token = $this->getResponse('/oauth/token', $options);
        $this->config->setBearer($token['access_token']);
        return $token;
    }