/**
  * 保存密码
  */
 public function saveAction()
 {
     /* @var $daoOrg Dao_Md_Org_Org */
     $daoOrg = $this->getDao('Dao_Md_Org_Org');
     // 判读是否为超级管理
     if (!$this->_user->isOwner()) {
         return $this->json(false, '您不是超级管理员');
     }
     $post = $this->_request->getPost();
     $auth = Tudu_Auth::getInstance();
     $adapter = new Tudu_Auth_Adapter_User($this->_multidb->getDefaultDb(), null, null, array('ignorelock' => true, 'skiplock' => true));
     $auth->setAdapter($adapter);
     $result = $auth->checkPassword($this->_user->userName, $post['oldpwd']);
     if (!$result->isValid()) {
         return $this->json(false, '当前密码输入错误');
     }
     if (empty($post['pwd'])) {
         return $this->json(false, '新密码不能为空');
     }
     if ($post['pwd'] != $post['repwd']) {
         return $this->json(false, '您输入的新密码与确认密码不一致');
     }
     /* @var $daoUser Dao_Md_User_User */
     $daoUser = $this->getDao('Dao_Md_User_User');
     $ret = $daoUser->updateUserInfo($this->_orgId, $this->_user->userId, array('password' => $post['pwd']));
     if (!$ret) {
         return $this->json(false, '修改密码失败');
     }
     return $this->json(true, '修改密码成功');
 }
Beispiel #2
0
 /**
  * Returns an instance of Tudu_Auth
  *
  * Singleton pattern implementation
  *
  * @return Tudu_Auth Provides a fluent interface
  */
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Beispiel #3
0
 /**
  * 修改密码
  */
 public function passwordAction()
 {
     $pwd = $this->_request->getPost('password');
     $opwd = $this->_request->getPost('opassword');
     $repwd = $this->_request->getPost('repassword');
     if ($this->session->isdemo) {
         return $this->json(false, $this->lang['password_deny_to_demoaccount']);
     }
     // 验证原密码
     $auth = Tudu_Auth::getInstance();
     $auth->setAdapter(new Tudu_Auth_Adapter_User($this->multidb->getDb(), null, null, array('ignorelock' => true, 'skiplock' => true)));
     $result = $auth->checkPassword($this->_user->userName, $opwd);
     if (!$result->isValid()) {
         return $this->json(false, $this->lang['old_password_unmatch']);
     }
     if ($pwd != $repwd) {
         return $this->json(false, $this->lang['confirm_password_unmatch']);
     }
     // 安全级别匹配
     $regs = array(1 => '/[0-9a-zA-Z]/', 2 => '/[0-9a-zA-Z^a-zA-Z0-9]/');
     $pwdLevel = isset($this->_user->option['passwordlevel']) ? $this->_user->option['passwordlevel'] : 0;
     if ($pwdLevel > 0 && !preg_match($regs[$pwdLevel], $pwd)) {
         return $this->json(false, $this->lang['password_level_not_match_' . $pwdLevel]);
     }
     $daoUser = Oray_Dao::factory('Dao_Md_User_User', $this->multidb->getDb());
     $params = array('password' => $pwd);
     $ret = $daoUser->updateUserInfo($this->_user->orgId, $this->_user->userId, $params);
     $ret = $daoUser->updateUser($this->_user->orgId, $this->_user->userId, array('initpassword' => 0));
     if (!$ret) {
         return $this->json(false, $this->lang['password_update_failure']);
     }
     $this->cache->deleteCache('TUDU-USER-' . $this->_user->userId . '@' . $this->_user->orgId);
     $this->json(true, $this->lang['password_update_success']);
 }