public function editAction($id) { $this->tag->setTitle('Quản lý thành viên: Chỉnh sửa'); $this->view->title_action = 'Thêm mới'; $model = $this->findFirstById($id); $this->view->form = $this->getForm($model); if ($this->request->isPost() == true) { if ($_POST['password'] != $model->password) { $hash = new \Modules\Library\Hash(); $_POST['password'] = $hash->create(md5($_POST['password']), $model->salt); } $this->save($_POST, $model); } }
/** * Checks the user credentials * * @param array $credentials * @return boolan */ public function check($credentials) { // Check if the user exist $conditions = "(email = :email: OR username = :username:) AND status = '1'"; $member = \Modules\Backend\Models\Member::findFirst(array("conditions" => $conditions, "bind" => array("email" => $credentials['username'], "username" => $credentials['username']))); if (!$member) { // không đúng tài khoản hoặc email thì return return false; } // Kiểm tra password đúng hay không $hash = new \Modules\Library\Hash(); if ($member->password !== $hash->create($credentials['password'], $member->salt)) { return false; } $this->session->set('auth-identity', array('id' => $member->id, 'username' => $member->username, 'firstname' => $member->firstname, 'lastname' => $member->lastname, 'group_id' => $member->group_id, 'permission' => $member->permission_group->permission, 'resource' => $member->permission_group->resource_id)); //Cấp quyen Update FILE bằng CKFINDER $this->setPermissionCKFinder(); return true; }
/** * Checks the user credentials * * @param array $credentials * @return boolan */ public function check($credentials) { // Check if the user exist $conditions = "(email = :email: OR username = :username:)"; $guest = \Modules\Frontend\Models\Guest::findFirst(array("conditions" => $conditions, "bind" => array("email" => $credentials['username'], "username" => $credentials['username']))); if (!$guest) { return 3; // // không đúng tài khoản hoặc email } else { if ($guest->status == 0) { return 2; //tài khoản chưa kích hoạt } // Kiểm tra password đúng hay không $hash = new \Modules\Library\Hash(); if ($guest->password !== $hash->create($credentials['password'], $guest->salt)) { return 1; // Không đúng mật khẩu } $this->session->set('auth-guest', array('id' => $guest->id, 'username' => $guest->username, 'firstname' => $guest->firstname, 'lastname' => $guest->lastname, 'permission' => $guest->guest_group->permission)); return 0; } }