Commits

christiansalazar  committed 8f4ab23

FIX ISSUE #20

  • Participants
  • Parent commits 9c553b0

Comments (0)

Files changed (2)

File models/data/CrugeStoredUser.php

 
     public function validate($attributes = null, $clearErrors = true)
     {
+		// si el metodo de autenticacion es solo email, y, username es blanco
+		// se genera uno automaticamente:
+		if($this->scenario == 'insert'){
+		$declared_authmodes = CrugeUtil::config()->availableAuthModes;
+		if(count($declared_authmodes == 1)){
+			if(($declared_authmodes[0] == 'email') && ($this->username=='')){
+				$um = new CrugeUserManager();
+				$this->username = $um->generateNewUserName($this->email);
+			}else
+			if(($declared_authmodes[0] == 'username') && ($this->email=='')){
+				$this->email = $this->username.'@noemail.local';
+			}
+		}}
+
         // realiza la validacion normal sobre los atributos de este modelo
-        //
         $validateResult = parent::validate();
 
         // ahora realiza la validacion sobre aquellos campos personalizados

File views/ui/registration.php

 )); ?>
 <div class="row form-group-vert">
 	<h6><?php echo ucfirst(CrugeTranslator::t("datos de la cuenta"));?></h6>
-	<div class="col">
-		<?php echo $form->labelEx($model,'username'); ?>
-		<div class='item'>
-			<?php echo $form->textField($model,'username'); ?>
-			<p class='hint'><?php echo CrugeTranslator::t(
-				"nombre de usuario, solo letras o numeros empezando por letras");?></p>
-		</div>
-		<?php echo $form->error($model,'username'); ?>
-	</div>
-	<div class="col">
-		<?php echo $form->labelEx($model,'email'); ?>
-		<div class='item'>
-			<?php echo $form->textField($model,'email'); ?>
-			<p class='hint'><?php echo CrugeTranslator::t(
-				"su correo electronico");?></p>
-		</div>
-		<?php echo $form->error($model,'email'); ?>
-	</div>
+	<?php 
+		foreach (CrugeUtil::config()->availableAuthModes as $authmode){
+			echo "<div class='col'>";
+			echo $form->labelEx($model,$authmode);
+			echo $form->textField($model,$authmode);
+			echo $form->error($model,$authmode);
+			echo "</div>";
+		}
+	?>
 	<div class="col">
 		<?php echo $form->labelEx($model,'newPassword'); ?>
 		<div class='item'>