Example #1
0
 /**
  * @return string|\yii\web\Response
  */
 public function run()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->controller->redirect('/');
     }
     $model = new AccesoForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->controller->redirect('/');
     }
     $this->controller->layout = 'invitados';
     return $this->controller->render('acceso', ['model' => $model]);
 }
Example #2
0
 /**
  * Login usuario
  * @return array|Response
  */
 public function run()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->controller->redirect('/');
     }
     $model = new AccesoForm();
     $url_micuenta = Yii::$app->urlManagerMicuenta->baseUrl;
     $url_frontend = Yii::$app->urlManager->baseUrl;
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->controller->redirect($url_micuenta);
     }
     return $this->controller->redirect($url_frontend);
 }