Ejemplo n.º 1
0
 /**
  * Validate password
  *
  * @access public
  * @author Dao Anh Minh
  */
 public static function _validation_change_pass($old_pass, $account_id)
 {
     Validation::active()->set_message('change_pass', 'Mật khẩu cũ không đúng');
     $account = Model_Account::query()->where('id', $account_id)->where('password', Auth\Auth::instance()->hash_password($old_pass))->count();
     if ($account > 0) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
 /**
  * Check permission
  *
  * @param string $area
  * @param string $controller
  * @param string $action
  * @return boolean true|false
  *
  * @access protected
  * @author Dao Anh Minh
  */
 protected function check_permisstion($area, $controller, $action)
 {
     if (Auth\Auth::instance()->has_access("{$area}.{$controller}.[{$action}]")) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 3
0
 /**
  * Edit account
  *
  * @param integer $account_id account id
  *
  * @access public
  * @author Dao Anh Minh
  */
 public function action_edit($account_id)
 {
     $view = View::forge('admin/account/edit');
     $account = Model_Account::query()->where('id', $account_id)->get_one();
     if (empty($account)) {
         Session::set_flash('error', 'Tài khoản không tồn tại');
         Response::redirect('admin/account');
     }
     $view->err = array();
     $validate = Model_Account::validate($account_id);
     if (Input::method() == 'POST') {
         if ($validate->run()) {
             $account->set('password', Auth\Auth::instance()->hash_password(Input::post('confirm_pass')))->save();
             Session::set_flash('success', 'Đổi mật khẩu thành công');
             Response::redirect('admin/account');
         } else {
             Session::set_flash('error', 'Có lỗi xảy ra');
             $view->err = $validate->error_message();
         }
     }
     $this->template->title = 'Đổi mật khẩu';
     $this->template->content = $view;
 }