コード例 #1
0
 /**
  * 刪除逾期未通過Email認證的User
  * 3小時跑一次
  */
 public function actionClearExpireUser()
 {
     $expireTime = time() - Yii::$app->params["checkCodeExpired"];
     \common\models\entities\Member::deleteAll("status = 1 AND createtime<{$expireTime}");
     echo Yii::$app->controller->action->id . " Done!! \n\r";
     exit;
 }
コード例 #2
0
 public function actionFbRegister()
 {
     Yii::$app->params["tmpFb"] = true;
     Yii::$app->tool->setPageMetaData("確認基本資料");
     $this->subTitle = "確認基本資料";
     $session = Yii::$app->session;
     if (!isset($session['tmpUser'])) {
         throw new \yii\web\HttpException(400, "無法從Facebook獲取您相關的資料", $this->errorLayout);
     }
     $model = $session['tmpUser'];
     $model->scenario = "fb-insert";
     Member::deleteAll(["social_type" => $session['tmpUser']->social_type, "username" => $session['tmpUser']->username, "status" => 1]);
     if ($model->load(\Yii::$app->request->post())) {
         $model->attributes = array("username" => $session['tmpUser']->username, "password" => $session['tmpUser']->password, "chkpassword" => $session['tmpUser']->password, "name" => $session['tmpUser']->name, "social_type" => $session['tmpUser']->social_type, "status" => 1);
         if ($model->validate() && $model->save()) {
             //發mail
             $result = Yii::$app->tool->sendUserEmailCheckCode($model, EmailCheckCodes::TYPE_REGIST);
             if (!$result) {
                 throw new \yii\web\HttpException(400, Yii::$app->tool->formatErrorMsg($model->getErrors()), $this->errorLayout);
             }
             $maskMail = Yii::$app->tool->mask_email($model->email);
             Yii::$app->getSession()->setFlash('alert', "我們將發送一封Email到您的信箱 {$maskMail}, 請依照信中指示進行驗證");
             unset($session['tmpUser']);
             return $this->goHome();
         }
         //print_r($model->getErrors());exit;
     }
     return $this->render('fbRegister', array('model' => $model));
 }