예제 #1
0
파일: UserIdentity.php 프로젝트: zwq/unpei
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = User::model()->findByAttributes(array('UserName' => $this->username));
     //验证账户是否存在,存在则获取其机构ID
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         $organ = Organ::model()->findByPk($user->OrganID);
         $employ = OrganEmployees::model()->findByPk($user->EmployeID);
         //判断密码是否错误
         if (Yii::app()->getModule('user')->encrypting($this->password) !== $user->PassWord) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             if ($organ->IsBlack == 1) {
                 $this->errorCode = self::ERROR_BLACK;
             } else {
                 if ($organ->IsFreeze == 1) {
                     $this->errorCode = self::ERROR_FREEZE;
                 } else {
                     if ($organ->ExpirationTime && time() > $organ->ExpirationTime) {
                         $this->errorCode = self::ERROR_EXPIRATION;
                     } else {
                         if ($employ && $employ->ExpireTime && time() > $employ->ExpireTime) {
                             $this->errorCode = self::ERROR_EXPIRATION;
                         } else {
                             $this->_id = $user->ID;
                             $this->username = $user->UserName;
                             $this->errorCode = self::ERROR_NONE;
                         }
                     }
                 }
             }
         }
     }
     return !$this->errorCode;
 }
예제 #2
0
 public function actionDelemploy()
 {
     $id = Yii::app()->request->getParam("id");
     $success = OrganEmployees::model()->updateByPk($id, array('Status' => 1, 'UpdateTime' => time()));
     $resule = User::model()->deleteAll("EmployeID=:id", array(":id" => $id));
     $this->redirect(Yii::app()->createUrl('/member/employee/index'));
 }