예제 #1
0
파일: Active.php 프로젝트: dzlin/xyeh-yii
 /**
  * 验证激活
  * @return boolean 激活成功返回true
  */
 protected function active()
 {
     $model = UserActive::model();
     $active = $model->fetchUidByCode($this->code);
     if ($active) {
         unset($model);
         $model = User::model();
         $user = $model->findByPk($active->id);
         if ($user && $user->email == $this->email) {
             $user->status = User::STATUS_ENABLE;
             return $user->save();
         }
     }
     return false;
 }
예제 #2
0
파일: Register.php 프로젝트: dzlin/xyeh-yii
 /**
  * 生成用户激活码并加密返回
  * @return string
  */
 protected function code()
 {
     $code = Env::randStr(self::ACTIVE_CODE_LENGTH);
     $model = new UserActive();
     $model->code = $code;
     $model->uid = $this->uid;
     if ($model->save()) {
         return base64_encode(Yii::app()->securityManager->encrypt($code));
     }
 }