/** * Returns the PUT response * * @param \PSX\Data\RecordInterface $record * @param \PSX\Api\Version $version * @return array|\PSX\Data\RecordInterface */ protected function doUpdate(RecordInterface $record, Version $version) { // we can only change the password through the backend app if ($this->appId != 1) { throw new StatusCode\BadRequestException('Changing the password is only possible through the backend app'); } // check verify password if ($record->getNewPassword() != $record->getVerifyPassword()) { throw new StatusCode\BadRequestException('New password does not match the verify password'); } // change password $result = $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\User')->changePassword($this->userId, $record->getOldPassword(), $record->getNewPassword()); if ($result) { return array('success' => true, 'message' => 'Password successful changed'); } else { throw new StatusCode\BadRequestException('Changing password failed'); } }