/** * Filter password * * @param string $value */ public function filterPassword(&$value) { $value = User::getHashPassword($value); if ($value === false) { return $this->trans('user.entity.user.error_password_min', ['#MIN#' => 6]); } }
/** * Change password * * @return boolean */ public function save() { if ($this->isValid()) { if (!User::updatePassword($this->getValue(self::C_USER_ID), $this->getValue(self::C_NEW))) { return $this->trans('user.form.password.password_change_error'); } else { return true; } } return false; }
/** * Return SQL Builder * * @param array $sort * @param array $filter * @param type $offset * @param type $limit * @return \BX\DB\Filter\SqlBuilder */ protected function getList(array $sort, array $filter, $offset = null, $limit = null) { $return = User::finder()->sort($sort)->filter($filter); if ($offset !== null) { $return->offset($offset); } if ($limit !== null) { $return->limit($limit); } return $return; }
/** * Check old password * * @param string $value */ public function validatePassword(&$value) { if ($this->user !== null) { $hash = User::getHashPasswordByUserID($this->user->id); if ($hash === false) { return $this->trans('user.form.access_form.bad_password'); } $value = User::getHashPassword($value); if (!User::checkPasswordByHash($value, $hash)) { return $this->trans('user.form.access_form.bad_password'); } } }
/** * Update news category * * @param integer $id * @param array $category * @return integer */ public function update($id, $category) { $repo = $this->store()->getRepository('news_category'); $repo->appendLockTables(['tbl_news']); if (isset($category['USER_ID'])) { $user_id = intval($category['USER_ID']); $user = User::finder()->filter(['ID' => $user_id])->count(); if ($user == 0) { throw new \RuntimeException('User is not found'); } } $entity = $this->finder()->filter(['ID' => $id])->get(); if ($entity === false) { $repo->rollback(); throw new \RuntimeException("Error news category is not found."); } $entity->setData($category); return $this->store()->update($repo, $entity); }
/** * Delete user * * @param integer $id */ public function actionDelete($id) { $post = $this->request()->post()->get('DELETE'); if ($id > 0 && $post !== null) { if (intval($post['SESSION_ID']) === $this->session()->getId() && $post['ID'] > 0) { if (User::delete($post['ID'])) { $this->setFlash(self::FLASH_KEY, $this->trans('user.widgets.user_edit.delete_success')); $this->redirect($this->path_to_list); } } } }
/** * Update user * * @param integer $id * @return boolean */ public function update($id) { if ($this->isValid(false)) { if (!User::update($id, $this->getData())) { $error = Error::get(); if ($error instanceof ValidateException) { foreach ($error->all() as $key => $mess) { $this->fields[$key]->error[] = $mess; } } else { $mess = 'Message: ' . $error->getMessage() . '.Trace: ' . $error->getTraceAsString(); $this->log('user.form.edit')->err($mess); $this->addError($this->trans('user.form.edit.unknow_error')); } } else { return true; } } return false; }