Example #1
0
 /**
  * Registro de usuario
  * @param string $query
  */
 public function run()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->controller->redirect('/');
     }
     $model = new CrearCuentaForm();
     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())) {
         if ($user = $model->registrar()) {
             if (Yii::$app->getUser()->login($user)) {
                 return $this->controller->redirect('/');
             }
         }
     }
 }
Example #2
0
 public function testRegistroFormaIncorrecta()
 {
     $model = new CrearCuentaForm(['nombre' => 'troy becker', 'correo' => '*****@*****.**', 'clave' => 'some_password', 'term_cond' => false]);
     expect('nombre de usuario y correo electrónico están en uso, el usuario no debe crearse', $model->registrar())->null();
 }
Example #3
0
 /**
  * Crear usuario tipo empresa
  */
 private function crearUsuarioEmpresa()
 {
     $model = new CrearCuentaForm();
     $model->nombre = $this->nombre_usuario;
     $model->correo = $this->correo;
     $model->clave = Usuarios::CLAVE_TEMPORAL;
     $model->term_cond = true;
     $model->id_municipio = $this->id_municipio;
     if ($usuario = $model->registrarEmpresario()) {
         $this->id_usuario = $usuario->idusuario;
     }
 }