Ejemplo n.º 1
0
 public function testAccesoConExito()
 {
     $model = new AccesoForm(['correo' => '*****@*****.**', 'clave' => 'password_0']);
     $this->specify('el usuario debe ser capaz de iniciar sesión con las credenciales correctas', function () use($model) {
         expect('modelo debe iniciar sesión de usuario', $model->login())->true();
         expect('mensaje de error no se debe mostrar', $model->errors)->hasntKey('clave');
         expect('el usuario debe iniciar sesión en', Yii::$app->user->isGuest)->false();
     });
 }
Ejemplo n.º 2
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]);
 }
Ejemplo n.º 3
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);
 }