示例#1
0
 public function actionConfirm()
 {
     $table = new UsuarioDB();
     if (Yii::$app->request->get()) {
         //Obtenemos el valor de los parámetros get
         $id = Html::encode($_GET["id"]);
         $authKey = $_GET["authKey"];
         if ((int) $id) {
             //Realizamos la consulta para obtener el registro
             $model = $table->find()->where("id=:id", [":id" => $id])->andWhere("authKey=:authKey", [":authKey" => $authKey]);
             //Si el registro existe
             if ($model->count() == 1) {
                 $activar = UsuarioDB::findOne($id);
                 $activar->activate = 1;
                 if ($activar->update()) {
                     echo "Felicidades, tu registro se ha llevado a cabo correctamente, redireccionando ...";
                     echo "<meta http-equiv='refresh' content='8; " . Url::toRoute("site/login") . "'>";
                 } else {
                     echo "Ha ocurrido un error al realizar el registro, redireccionando ...";
                     echo "<meta http-equiv='refresh' content='8; " . Url::toRoute("site/login") . "'>";
                 }
             } else {
                 return $this->redirect(["site/login"]);
             }
         } else {
             return $this->redirect(["site/login"]);
         }
     }
 }