Пример #1
0
 public function authenticate()
 {
     $manager = Manager::model()->getArrByAttributes(array('name' => $this->name));
     if (empty($manager)) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($manager['status'] != Manager::MAN_STATUS_NORMAL) {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         } else {
             if (McryptComponent::decryption($manager['passwd']) != $this->password) {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
             } else {
                 $this->errorCode = self::ERROR_NONE;
                 $this->id = $manager['id'];
                 $this->sp = $manager['sp'];
             }
         }
     }
     return !$this->errorCode;
 }
Пример #2
0
 /**
  * 修改密码
  */
 public function modifyPasswd($id, $arr)
 {
     $result = 0;
     if ($arr['new'] == $arr['repeat']) {
         $manager = $this->findByPk($id);
         if (!empty($manager) && McryptComponent::decryption($manager->passwd) == $arr['old']) {
             $manager->passwd = McryptComponent::encryption($arr['new']);
             if ($manager->save()) {
                 $result = 1;
             }
         } else {
             $result = -1;
         }
     }
     return $result;
 }